Guide pratique avec exemples visuels et référence de 80+ balises
Squelette HTML5
<!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Titre</title> </head> <body> <!-- Contenu --> </body> </html>
<!DOCTYPE html> - Déclaration HTML5 (obligatoire)<html lang="fr"> - Élément racine + langue<head> - Conteneur métadonnées<body> - Contenu visibleBalises <head>
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="Description 160 car."> <meta name="author" content="Nom"> <meta name="robots" content="index, follow"> <meta http-equiv="refresh" content="30"> <title>Titre - Site</title> <base href="https://monsite.com/"> <link rel="icon" href="favicon.ico"> <link rel="stylesheet" href="style.css"> <link rel="canonical" href="https://url-officielle.com"> <style> body { margin: 0; } </style> <script src="app.js" defer></script>
defer ou async pour les scripts afin
de ne pas bloquer le rendu.Titres, paragraphes, mise en forme
strong - texte important (gras)
b - gras sans importance sémantique
em - emphase (italique)
i - italique sans emphase
u - souligné
s - texte barré (obsolète)
del - supprimé / ins - inséré
mark - surligné
small - petit texte
H2O - subscript / X2 - superscript
code - code inline
Ctrl + C - touche clavier
Sortie programme - sample output
x = 5 - variable
Citation courte inline
HTML - abréviation
Titre d'œuvre - citation
Terme - définition
Produit #123
Contact : email@site.com<strong>Important</strong> <b>Gras</b> <em>Emphase</em> <i>Italique</i> <u>Souligné</u> <s>Barré</s> <del>Supprimé</del> <ins>Inséré</ins> <mark>Surligné</mark> <small>Petit</small> <sub>Indice</sub> <sup>Exposant</sup> <code>Code</code> <kbd>Touche</kbd> <abbr title="...">ABR</abbr> <time datetime="2024-01-15">15 jan</time>
"Une citation longue avec la balise blockquote."
Texte
préformaté
avec espaces conservés
<br> - Saut de ligne<hr> - Ligne horizontale<wbr> - Point de coupure optionnelBalise <a>
<!-- Externe --> <a href="https://google.com">Google</a> <!-- Nouvel onglet (sécurisé) --> <a href="url" target="_blank" rel="noopener noreferrer">Lien</a> <!-- Interne --> <a href="/page.html">Page</a> <a href="./dossier/page.html">Relatif</a> <!-- Ancre --> <a href="#section">Vers section</a> <section id="section">Cible</section> <!-- Email / Téléphone --> <a href="mailto:contact@site.com">Email</a> <a href="tel:+33123456789">Appeler</a> <!-- Téléchargement --> <a href="doc.pdf" download>Télécharger</a> <a href="doc.pdf" download="nouveau-nom.pdf">Télécharger</a>
Multimédia HTML5
<!-- Image simple --> <img src="photo.jpg" alt="Description obligatoire"> <!-- Dimensions + lazy loading --> <img src="img.jpg" alt="..." width="400" height="300" loading="lazy"> <!-- Figure + légende --> <figure> <img src="img.jpg" alt="..."> <figcaption>Légende</figcaption> </figure> <!-- Image responsive --> <picture> <source media="(min-width:800px)" srcset="large.jpg"> <source media="(min-width:400px)" srcset="medium.jpg"> <img src="small.jpg" alt="..."> </picture> <!-- Image cliquable --> <a href="page.html"><img src="btn.png" alt="Bouton"></a>
<!-- Vidéo --> <video controls width="640" poster="thumb.jpg"> <source src="video.mp4" type="video/mp4"> <source src="video.webm" type="video/webm"> <track src="sous-titres.vtt" kind="subtitles" srclang="fr"> </video> <!-- Audio --> <audio controls loop muted> <source src="audio.mp3" type="audio/mpeg"> </audio> <!-- Iframe (YouTube, maps...) --> <iframe src="https://youtube.com/embed/ID" allowfullscreen loading="lazy"></iframe> <!-- Canvas / SVG --> <canvas id="c" width="300" height="200"></canvas> <svg width="100" height="100">...</svg>
Organisation des données
| Nom | Rôle | |
|---|---|---|
| Alice | alice@mail.com | Admin |
| Bob | bob@mail.com | User |
| Charlie | charlie@mail.com | User |
| 3 utilisateurs | ||
<table> <caption>Titre du tableau</caption> <colgroup><col span="2"><col></colgroup> <thead> <tr><th>Col 1</th><th>Col 2</th></tr> </thead> <tbody> <tr><td>A</td><td>B</td></tr> <tr><td colspan="2">Fusionné</td></tr> <tr><td rowspan="2">2 lignes</td><td>X</td></tr> </tbody> <tfoot><tr><td colspan="2">Pied</td></tr></tfoot> </table>
Inputs et validation
<input required> <!-- Obligatoire --> <input minlength="3" maxlength="20"> <!-- Longueur --> <input min="0" max="100" step="5"> <!-- Nombre --> <input pattern="[A-Za-z]{3}"> <!-- Regex --> <input placeholder="Indice"> <!-- Placeholder --> <input readonly> <!-- Lecture seule --> <input disabled> <!-- Désactivé --> <input autofocus> <!-- Focus auto --> <input autocomplete="off"> <!-- Pas d'auto-complétion -->
Structure moderne
<body> <header> <nav>Navigation</nav> </header> <main> <article> <header>En-tête article</header> <section>Section 1</section> <section>Section 2</section> <footer>Pied article</footer> </article> <aside>Sidebar</aside> </main> <footer>Pied de page</footer> </body>
Contenu caché révélé au clic. Très utile pour les FAQ!
Avec l'attribut open
Rendre le web utilisable par tous
1. Contraste : Le texte et le fond doivent avoir un contraste suffisant (ratio 4.5:1).
2. Structure : Utiliser les balises sémantiques (h1-h6,
nav, button) pour que les lecteurs d'écran comprennent la
page.
3. Clavier : Tout doit être accessible sans souris (Tabulation).
<!-- Alt pour images --> <img src="cat.jpg" alt="Chat noir qui dort sur un canapé"> <!-- Label pour formulaires --> <label for="email">Email</label> <input id="email" type="email"> <!-- ARIA (si HTML ne suffit pas) --> <div role="alert" aria-live="polite">Erreur de connexion</div>
Optimisation pour les moteurs
<meta property="og:title" content="Mon Article"> <meta property="og:image" content="https://site.com/thumb.jpg"> <meta property="og:description" content="Résumé...">
<!-- Lazy loading --> <img loading="lazy" ...> <iframe loading="lazy" ...></iframe> <!-- Preload (Police critique) --> <link rel="preload" href="font.woff2" as="font">
80+ balises HTML5
<!DOCTYPE> <html> <head>
<body>
<title> <meta> <link>
<style> <script> <base>
<noscript>
<header> <nav> <main>
<article> <section> <aside>
<footer> <address> <hgroup>
<h1> <h2> <h3>
<h4> <h5> <h6>
<p> <div> <pre>
<blockquote> <hr>
<strong> <em>
<mark> <cite> <q> <dfn>
<abbr> <time> <data>
<b> <i> <u>
<s> <small> <sub> <sup>
<del> <ins>
<code> <kbd> <samp>
<var>
<br> <wbr> <span>
<a> <nav>
<img> <figure> <figcaption>
<picture> <source> <map>
<area>
<video> <audio> <track>
<iframe> <embed> <object>
<param>
<canvas> <svg>
<ul> <ol> <li>
<dl> <dt> <dd>
<menu>
<table> <caption>
<thead>
<tbody> <tfoot> <tr>
<th> <td> <colgroup>
<col>
<form> <fieldset>
<legend> <label>
<input> <textarea>
<select>
<option> <optgroup> <datalist>
<button>
<output> <progress>
<meter>
<details> <summary>
<dialog>
<script> <noscript>
<template> <slot>
<ruby> <rt>
<rp>
<bdi> <bdo>