<> HTML Foundations

Understand semantic HTML, document structure, forms, accessibility and SEO-ready markup.

Lessons

Sign in to save progress
1 HTML Tutorial 2 HTML HOME 3 HTML Introduction 4 HTML Editors 5 HTML Basic 6 HTML Elements 7 HTML Attributes 8 HTML Headings 9 HTML Paragraphs 10 HTML Styles 11 HTML Formatting 12 HTML Quotations 13 HTML Comments 14 HTML Colors 15 HTML CSS 16 HTML Links 17 HTML Images 18 HTML Favicon 19 HTML Page Title 20 HTML Tables 21 HTML Lists 22 HTML Block & Inline 23 HTML Div 24 HTML Classes 25 HTML Id 26 HTML Buttons 27 HTML Iframes 28 HTML JavaScript 29 HTML File Paths 30 HTML Head 31 HTML Layout 32 HTML Responsive 33 HTML Computercode 34 HTML Semantics 35 HTML Style Guide 36 HTML Entities 37 HTML Symbols 38 HTML Emojis 39 HTML Charsets 40 HTML URL Encode 41 HTML vs. XHTML 42 HTML Forms 43 HTML Form Attributes 44 HTML Form Elements 45 HTML Input Types 46 HTML Input Attributes 47 Input Form Attributes 48 HTML Graphics 49 HTML Canvas 50 HTML SVG 51 HTML Media 52 HTML Video 53 HTML Audio 54 HTML Plug-ins 55 HTML YouTube 56 HTML Web APIs 57 HTML Geolocation 58 HTML Drag and Drop 59 HTML Web Storage 60 HTML Web Workers 61 HTML SSE 62 HTML Certificate 63 HTML Examples 64 HTML Editor 65 HTML Quiz 66 HTML Exercises 67 HTML Challenges 68 HTML Website 69 HTML Syllabus 70 HTML Study Plan 71 HTML Interview Prep 72 HTML Bootcamp 73 HTML Summary 74 HTML Accessibility 75 HTML References 76 HTML Tag List 77 HTML Attributes Reference 78 HTML Global Attributes 79 HTML Browser Support 80 HTML Events 81 HTML Colors Reference 82 HTML Canvas Reference 83 HTML Audio/Video 84 HTML Doctypes 85 HTML Character Sets 86 HTML URL Encode Reference 87 HTML Lang Codes 88 HTTP Messages 89 HTTP Methods 90 PX to EM Converter 91 Keyboard Shortcuts

HTML Links

HTML Foundations Lesson 16 of 91 ~7 min read

Overview

HTML Links is part of the complete HTML syllabus. This lesson explains the concept deeply, shows the exact tags or attributes to use, and gives you a runnable browser example for practice.

HTML Links is about choosing markup that carries meaning before styling begins. Good HTML gives the page a reliable structure, makes the content easier to maintain, and gives browsers, search engines, forms, and assistive technologies the information they need.

Core Ideas

  • Use HTML Links to improve the meaning of the document, not only the appearance.
  • Keep labels, headings, landmarks, and relationships explicit.
  • Prefer built-in browser behavior whenever it already solves the job.
  • Check that the page still makes sense when CSS and JavaScript are unavailable.

Step by Step

  1. Identify the content relationship that HTML Links needs to express.
  2. Choose the native element, attribute, or browser API that matches that relationship.
  3. Add the smallest useful markup first, then add progressive enhancements.
  4. Validate the result with keyboard navigation, browser tools, and source inspection.

Beginner Explanation

HTML Links explains how one page connects to other pages, files, images, scripts, stylesheets, and external resources.

Links use href, images use src, and many resources need alt text, size information, or relationship attributes.

Use clear paths and meaningful link text. Users should know where a link goes before clicking it.

Before You Start

  • Know whether HTML Links points to a page, file, image, section, script, stylesheet, or external site.
  • Check the folder location so relative paths resolve correctly.
  • Write useful text alternatives before adding images or vague links.

Key Tags and Attributes

  • a href: creates navigation to another URL or file.
  • img src: loads an image resource.
  • alt: describes meaningful images and can be empty for decorative ones.
  • rel: explains the relationship between the current page and linked resource.

Plain-English Glossary

  • href: the destination used by links and some resource references.
  • src: the file source used by images, scripts, iframes, and media.
  • Alt text: a text alternative for meaningful images.
  • Relative path: a file path resolved from the current document location.

What You Will Learn

  • Use HTML Links to connect the current document to pages, files, images, anchors, and external resources.
  • Choose the right path type: root-relative, document-relative, absolute URL, or fragment link.
  • Write link text and alt text that still makes sense out of context.
  • Reserve space for images and media to reduce layout movement while loading.

Where You Use This in Real Projects

You use HTML Links whenever a page points to another route, image, download, stylesheet, script, anchor, or external site.

Clear resource markup prevents broken links, missing images, unsafe external navigation, and confusing link text.

When to Use This

  • Use HTML Links whenever the page needs to navigate, load, download, embed, or reference another resource.
  • Use relative paths for project files and absolute URLs for external destinations.
  • Use plain text instead when there is no real destination or resource to load.

Browser and Accessibility Notes

  • Broken href and src values are among the easiest HTML problems to miss.
  • External links that open a new tab should use rel="noopener noreferrer".
  • Images need meaningful alt text unless they are purely decorative.
  • Width and height let the browser reserve space before the image finishes loading.

Code Example

<nav aria-label="Lesson navigation">
  <a href="/learn/html">HTML lessons</a>
  <a href="../assets/guide.pdf" download>Download guide</a>
  <a href="https://example.com" rel="noopener noreferrer">External resource</a>
</nav>

Another Example

<article>
  <h2>Recommended resource</h2>
  <a href="/learn/html/html-links">Read the links lesson</a>
  <img src="/images/html-card.png" alt="HTML lesson preview" width="320" height="180">
</article>

Example Explained

  • The href attribute points the link to another page.
  • The img src points to an image file.
  • The alt text explains the image for users who cannot see it.
  • Width and height help the browser reserve space before the image loads.

How to Read This Example

  1. Start by identifying the resource type in the HTML Links example: link, image, file path, script, stylesheet, or embedded content.
  2. Read href and src values carefully. They tell the browser where to go or what to load.
  3. Check text alternatives, link text, rel attributes, width, height, and loading behavior.
  4. Click the link or inspect the network request to confirm the path resolves correctly.

Code Editor Example

Open a ready-made starter for this lesson in the live HTML, CSS, and JavaScript editor. You can change the code, then click Run to see the result immediately.

Open in Code Editor

Checklist

  • Use the most specific native element before reaching for a div.
  • Check the page with keyboard navigation and browser validation.
  • Keep the markup readable before adding CSS or JavaScript.

Common Mistakes

  • Using divs for everything and losing built-in semantics.
  • Adding JavaScript for behavior the browser already provides.
  • Forgetting labels, alt text, lang, viewport, or metadata that other tools rely on.

Do and Don't

  • Do: check every href and src used in HTML Links.
  • Do: write useful link text and meaningful image alt text.
  • Don't: use vague link text like click here when the destination matters.
  • Don't: omit rel="noopener noreferrer" for external links that open new tabs.

Practice Challenge

Recreate the HTML Links example in the code editor, then inspect the DOM and check that labels, links, and metadata still make sense without CSS.

Try These Changes

  • Change the text in the HTML Links example and run it again.
  • Add one new related element, such as another paragraph, list item, table row, input, or link.
  • Add a class name and write a small CSS rule for it in the CSS tab.
  • Break one tag on purpose, run it, then fix it so you understand how browsers recover from mistakes.

Quick Check

  • Question: What is href for? Answer: It is the destination of a link.
  • Question: What is alt for? Answer: It describes meaningful images.
  • Question: Why add image width and height? Answer: It reduces layout shift while the image loads.

Revision Questions

  • Which attributes point to another resource in HTML Links?
  • Is each path relative, root-relative, absolute, or a fragment?
  • What will users understand from the link text or alt text?
  • What should happen if the resource fails to load?

Debugging Checks

  • Click every link and check for broken, redirected, or unsafe destinations.
  • Inspect image requests and confirm the src path is correct.
  • Check that alt text describes meaning, not just the file name.
  • Use browser dev tools to see whether relative paths resolve where you expected.

Mini Project

Build a resource card with one internal link, one external link, one download link, and one image. Check every path and make the link text understandable without surrounding context.

Mastery Check

  • You can explain why the chosen HTML for HTML Links is more meaningful than a generic div.
  • You can identify the keyboard and accessibility behavior provided by the browser.
  • You can extend the example without breaking validation.
Create a free account to save which lessons you've finished. Save my progress