FSM Full Stack Masterclass
Platform under construction
HTML course badge

HTML Attributes

Intermediate

HTML Link Attributes

Learn href, target, rel, download, hreflang as part of the HTML attribute system: what they configure, where they belong and which mistakes to avoid.

Links

Link attributes decide where users go and how safely they get there.

A link without href is just text with link styling. The href attribute gives it a destination. Other link attributes control new tabs, downloads, relationship hints and security behavior.

Because links move people through a site, link attributes affect usability, SEO, accessibility and trust.

Attribute group: href, target, rel, download, hreflang. Attributes that decide where links go and how safely they open.

What belongs here

Learn attributes by purpose, not by memorizing random names.

href

The destination: page, file, section, email, phone or protocol URL.

target

Controls where the link opens, such as _blank for a new tab.

rel

Describes the relationship and can improve security with noopener.

download

Suggests that the browser downloads the file instead of navigating.

Syntax in context

A real link needs a clear href.

Use descriptive link text and add rel="noopener" when target="_blank" opens an external page.

<a href="/html/elements/">Learn HTML elements</a>
<a href="https://example.com" target="_blank" rel="noopener">
  Open external reference
</a>

Good versus weak

Small attribute choices can change behavior, accessibility and security.

Good

<a href="/html/elements/">Learn HTML elements</a>
<a href="https://example.com" target="_blank" rel="noopener">
  Open external reference
</a>

Weak

<a onclick="goSomewhere()">Click here</a>
<a href="https://example.com" target="_blank">External site</a>

Rules that matter

Use these rules before publishing real HTML.

Use meaningful text

The link text should make sense without reading the full paragraph around it.

Protect new tabs

Use rel="noopener" with target="_blank" for external links.

Use anchors for sections

href="#section-id" jumps to an element with that id.

Do not fake links

If it navigates, use a. If it performs an action, use button.

Production thinking

Attributes are tiny pieces of HTML with real product impact.

Why does this matter?

Attributes are small, but they change how an element works. A good attribute can make a link usable, an image understandable, a form easier to complete or a script safer to load.

Accessibility

Screen reader users often navigate link by link. Descriptive link text is more useful than "click here".

Production note

Broken href values create dead ends. Link checks and stable URLs matter on real sites.

Live code lab

Change the code and run the example.

Edit the HTML or CSS, then use Run to refresh the preview. The preview is isolated, so links and forms stay inside this practice area.

Mini assignment

Try this now.

  • Change one tag, attribute or text value in the example.
  • Run the preview and describe exactly what changed.
  • Reset the lab and repeat the same change without looking at the original.

Practice assignment

Do this before moving to the next lesson.

  1. Change one meaningful part of the HTML, not only the visible text.
  2. Run the preview and check whether the result still makes semantic sense.
  3. Explain why the element or attribute you changed belongs in this exact place.

Try it yourself

Safe and clear links

Live preview

Self-check

Before you continue, prove that you own this lesson.

Intermediate

Do not only read this page. Answer these questions out loud or write the answers in your own notes. If one answer feels vague, revisit the examples before moving on.

  1. Can you explain what problem this lesson solves in a real website?
  2. Can you identify the most important tag or attribute from this lesson?
  3. Can you name one accessibility mistake this lesson helps prevent?
  4. Can you write one good example and one weak example without copying the page?
  5. Can you explain when you would use this in production and when you would avoid it?