The <a> (anchor) element creates a hyperlink. Its href is the destination, which can be a URL, a path, an in-page anchor, or a special scheme.
External site
Internal page (relative)
Jump to an element with id="section2"
Send email
Call us
The <a> (anchor) element creates a hyperlink. Its href is the destination, which can be a URL, a path, an in-page anchor, or a special scheme.
External site
Internal page (relative)
Jump to an element with id="section2"
Send email
Call us
<a href="https://other.com" target="_blank" rel="noopener noreferrer">
Opens in a new tab
</a>
target="_blank" abre uma nova aba, mas você deve adicionar rel="noopener": sem isso, a nova página pode acessar window.opener e potencialmente redirecionar sua página (um ataque "tab-nabbing"). noreferrer também remove o cabeçalho referrer. Navegadores modernos implicam noopener para _blank, mas adicioná-lo explicitamente é a melhor prática.
<a href="..." rel="nofollow">Don't pass SEO ranking (untrusted/user links)</a>
<a href="..." rel="noopener">Security: no window.opener access</a>
<a href="..." rel="sponsored">Paid/affiliate link</a>
<a href="#top">Back to top</a>
...
<div id="top">...</div> <!-- the link scrolls here -->
Clicar rola para o elemento cujo id corresponde ao fragmento.
Os âncoras são a espinha dorsal da navegação da web.
Conhecer os esquemas href (relativo, absoluto, fragmento, mailto/tel), o par de segurança target="_blank" + rel="noopener" e os valores rel relevantes para SEO é essencial para vinculação correta e segura.