FSM Full Stack Masterclass
Platform under construction
HTML course badge

HTML Attributes

Intermediate

HTML Security Attributes

Learn rel, sandbox, integrity, crossorigin, referrerpolicy as part of the HTML attribute system: what they configure, where they belong and which mistakes to avoid.

Security

Security attributes reduce risk at the edges of a page.

HTML loads resources, opens links and embeds external content. Security-related attributes help control those boundaries.

They do not replace server security, content security policy or careful dependency choices. They are one layer in a larger defense.

Attribute group: rel, sandbox, integrity, crossorigin, referrerpolicy. Attributes that reduce risk when loading or linking external resources.

What belongs here

Learn attributes by purpose, not by memorizing random names.

rel="noopener"

Prevents a new tab from controlling the opener window.

sandbox

Restricts iframe capabilities.

integrity

Checks that a loaded resource matches an expected hash.

crossorigin

Controls cross-origin resource requests for certain elements.

referrerpolicy

Limits what referrer information is sent.

download

Can change navigation into file download behavior.

Syntax in context

Security attributes belong where trust boundaries exist.

Use them on external links, iframes, scripts, styles and resources loaded from outside your own origin.

<a href="https://example.com" target="_blank" rel="noopener noreferrer">
  Open external site
</a>
<script src="cdn.js" integrity="sha384-..." crossorigin="anonymous"></script>

Good versus weak

Small attribute choices can change behavior, accessibility and security.

Good

<a href="https://example.com" target="_blank" rel="noopener noreferrer">
  Open external site
</a>
<script src="cdn.js" integrity="sha384-..." crossorigin="anonymous"></script>

Weak

<a href="https://example.com" target="_blank">External</a>
<iframe src="https://unknown.example"></iframe>

Rules that matter

Use these rules before publishing real HTML.

Protect external tabs

target="_blank" should normally include rel="noopener".

Do not overtrust embeds

Sandbox iframes unless you know exactly why not.

Use SRI for CDN assets

Integrity helps detect unexpected third-party file changes.

Limit referrers where needed

Referrer policy can reduce accidental data leakage.

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

Security attributes should not hide the purpose of links or embedded content. Users still need clear labels and context.

Production note

Security attributes are small but important hardening details, especially on pages with third-party content.

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

Safer external edges

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?