(Nota:. Migrato da https://webmasters.stackexchange.com/a/30031/10884 e curato per brevità)
Se avete bisogno di saltare agli utenti di collegamenti in-page, noto anche come identificatori di frammento, è possibile impostare l'attributo id
(che è used for more than just frag ids) su qualsiasi elemento. Quindi utilizzare il solito #
nell'URL di un attributo href
di un elemento a
. Ecco un esempio:
<body>
<p>Despite the many
<a href="#benefits-of-gum-chewing">benefits</a>
you may experience while chewing gum, there are also many drawbacks,
especially with
<a href="http://www.example.org/sugar.html#cons">non-sugarless</a>
gum.</p>
...
<section id="benefits-of-gum-chewing">
<h1>Benefits of Gum Chewing</h1>
...
</section>
</body>
Quando si scrivono le mie pagine, Vorrei dare un id
ad ogni <section>
tag (HTML5), anche se non ho intenzione di usarlo. Il valore di id
è una versione compatibile con l'URL del contenuto della sua intestazione. È possibile ottenere lo stesso effetto assegnando lo stesso id
a un <h1>
, ecc
Questa domanda è già stata posta qui: https://webmasters.stackexchange.com/q/12798/10884 – chharvey