Performance: Anchor tag basics
Anchor tags affect page load speed by triggering navigation and can impact interaction responsiveness when used improperly.
<a href="/target-page" aria-label="Go to target page">Click me</a>
<a href="#" onclick="doSomething(); return false;">Click me</a>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Anchor with href="#" and inline JS | Minimal DOM nodes | 1 reflow on click | Low paint cost | [X] Bad |
| Anchor with valid href and no inline JS | Minimal DOM nodes | 0 reflows on click | Low paint cost | [OK] Good |
<a> tag do in HTML?href inside the <a> tag.href and link text correctly. Other options use wrong attributes or tags.<a href="#section2">Go to Section 2</a>
<h2 id="section2">Section 2</h2>
<a href="www.example.com">Example</a>
mailto: protocol in the href attribute to open the email client.mailto:contact@example.com correctly. <a href="email:contact@example.com">Send Email</a> uses wrong protocol 'email:', while others lack the protocol or use incorrect formats like 'mailto://'.Pass the test and this pattern moves unknown