Créer un sommaire avec des liens internes – ancre (anchor) sur WordPress |
Article original Publié le : 31 aout 2020 Mise a jour le : – |
Voici le code html a mettre dans l’article
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<p id="sommaire">Sommaire</p> <ul style="list-style-type: disc;"> <li><a href="#ancre1">Chapitre 1</a></li> <li><a href="#ancre2">Chapitre 2</a></li> <li><a href="#ancre3">Chapitre 3</a></li> </ul> <h2 id="ancre1">Chapitre 1 <a href="#sommaire"><span style="font-size: 8pt;">UP</span></a></h2> Texte lié au chapitre 1 <h2 id="ancre2">Chapitre 2 <a href="#sommaire"><span style="font-size: 8pt;">UP</span></a></h2> Texte lié au chapitre 2 <h2 id="ancre3">Chapitre 3 <a href="#sommaire"><span style="font-size: 8pt;">UP</span></a></h2> Texte lié au chapitre 3 |
En détail
<li></li> marquer une puce : voir
est un espace insécable : voir <h2></h2> balise titre : voir <p></p> balise paragraphe : voir <a href=”#ancre1″></a> est le lien qui doit être égale au nom de l’ancre id=”ancre1″ : voir |
Ce qui donne le résultat suivant
Sommaire
Chapitre 1 UP
Texte lié au chapitre 1
Chapitre 2 UP
Texte lié au chapitre 2
Chapitre 3 UP
Texte lié au chapitre 3