Tableaux HTML et CSS
Structure, fusion de cellules et mise en forme complète
1. Structure d’un tableau
Un tableau représente des données en lignes et colonnes ; il ne sert pas à construire toute une page. tr forme une ligne, th un en-tête, td une donnée.
<table>
<caption>Résultats du trimestre</caption>
<thead>
<tr>
<th scope="col">Matière</th>
<th scope="col">Note</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">HTML</th>
<td>5,5</td>
</tr>
<tr>
<th scope="row">CSS</th>
<td>5,0</td>
</tr>
</tbody>
<tfoot>
<tr>
<th scope="row">Moyenne</th>
<td>5,25</td>
</tr>
</tfoot>
</table>La légende et les en-têtes donnent du sens aux valeurs.
| Balise | Rôle |
|---|---|
caption | Titre descriptif. |
thead | Lignes d’en-tête. |
tbody | Lignes de données. |
tfoot | Lignes de synthèse. |
tr | Une ligne. |
th scope="col" | En-tête de colonne. |
th scope="row" | En-tête de ligne. |
td | Cellule de données. |
2. Fusionner des cellules
<table>
<caption>Planning</caption>
<thead>
<tr>
<th scope="col">Jour</th>
<th scope="col">Matin</th>
<th scope="col">Après-midi</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Lundi</th>
<td colspan="2">Atelier HTML</td>
</tr>
<tr>
<th scope="row">Mardi</th>
<td rowspan="2">Projet CSS</td>
<td>Révision</td>
</tr>
<tr>
<th scope="row">Mercredi</th>
<td>Présentation</td>
</tr>
</tbody>
</table>Lundi occupe deux colonnes ; Projet CSS occupe deux lignes.
colspan="2" occupe deux colonnes ; rowspan="2" occupe deux lignes. Une cellule fusionnée remplace les cellules couvertes. La cellule « Projet CSS » occupe ainsi aussi le matin de mercredi.
3. CSS pour le tableau
<div class="tableauDefilement">
<table>
<caption>Tarifs des ateliers</caption>
<thead>
<tr>
<th>Atelier</th>
<th>Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th>Découverte</th>
<td>Gratuit</td>
</tr>
<tr>
<th>Création</th>
<td>25 CHF</td>
</tr>
</tbody>
</table>
</div>.tableauDefilement { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
caption { text-align: left; font-weight: 700; margin-bottom: .5rem; }
th, td { border: 1px solid #a9bbca; padding: .7rem .9rem; text-align: left; }
thead { background: #164b6a; color: white; }
tbody tr:nth-child(even) { background: #eef5f7; }
tbody tr:hover { background: #d9edf2; }
tfoot { background: #e1e9ee; font-weight: 700; }Les traits voisins ne forment plus deux bordures séparées.
border-collapse: collapse fusionne les bordures voisines. :nth-child(even) alterne les lignes paires ; :hover aide au suivi du regard. Le conteneur à overflow-x: auto évite de supprimer des colonnes sur petit écran.
4. Exemple complet
<div class="tableauDefilement">
<table>
<caption>Tarifs des ateliers</caption>
<thead>
<tr>
<th scope="col">Atelier</th>
<th scope="col">Durée</th>
<th scope="col">Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Découverte</th>
<td>1 h</td>
<td>Gratuit</td>
</tr>
<tr>
<th scope="row">Création</th>
<td>2 h</td>
<td>25 CHF</td>
</tr>
</tbody>
</table>
</div>La légende et les en-têtes donnent du sens aux valeurs.
| Atelier | Durée | Prix |
|---|---|---|
| Découverte | 1 h | Gratuit |
| Création | 2 h | 25 CHF |
5. Comparer border-collapse et border-spacing
Quatre réglages montrent précisément la différence entre des bordures séparées, fusionnées et espacées.
Bordures séparées, espace nul
<table>
<caption>Tarifs des ateliers</caption>
<thead>
<tr>
<th>Atelier</th>
<th>Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th>Découverte</th>
<td>Gratuit</td>
</tr>
<tr>
<th>Création</th>
<td>25 CHF</td>
</tr>
<tr>
<th>Expert</th>
<td>40 CHF</td>
</tr>
</tbody>
</table>table {
width:100%
}
caption {
text-align:left;
font-weight:700;
margin-bottom:8px
}
th,td {
border:2px solid #8699b4;
padding:8px;
text-align:left
}
table {
border-collapse:separate;
border-spacing:0
}À remarquer : Chaque cellule garde sa bordure. Au contact, deux traits de 2 px se touchent : la ligne paraît plus épaisse.
Bordures fusionnées
<table>
<caption>Tarifs des ateliers</caption>
<thead>
<tr>
<th>Atelier</th>
<th>Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th>Découverte</th>
<td>Gratuit</td>
</tr>
<tr>
<th>Création</th>
<td>25 CHF</td>
</tr>
<tr>
<th>Expert</th>
<td>40 CHF</td>
</tr>
</tbody>
</table>table {
width:100%
}
caption {
text-align:left;
font-weight:700;
margin-bottom:8px
}
th,td {
border:2px solid #8699b4;
padding:8px;
text-align:left
}
table {
border-collapse:collapse
}À remarquer : Les bordures voisines deviennent un seul trait. C’est le rendu courant pour un tableau quadrillé.
Cellules espacées
<table>
<caption>Tarifs des ateliers</caption>
<thead>
<tr>
<th>Atelier</th>
<th>Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th>Découverte</th>
<td>Gratuit</td>
</tr>
<tr>
<th>Création</th>
<td>25 CHF</td>
</tr>
<tr>
<th>Expert</th>
<td>40 CHF</td>
</tr>
</tbody>
</table>table {
width:100%
}
caption {
text-align:left;
font-weight:700;
margin-bottom:8px
}
th,td {
border:2px solid #8699b4;
padding:8px;
text-align:left
}
table {
border-collapse:separate;
border-spacing:12px
}À remarquer : Un espace de 12 px apparaît entre les cellules. border-spacing ne s’applique pas quand border-collapse vaut collapse.
Espacements horizontal et vertical
<table>
<caption>Tarifs des ateliers</caption>
<thead>
<tr>
<th>Atelier</th>
<th>Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th>Découverte</th>
<td>Gratuit</td>
</tr>
<tr>
<th>Création</th>
<td>25 CHF</td>
</tr>
<tr>
<th>Expert</th>
<td>40 CHF</td>
</tr>
</tbody>
</table>table {
width:100%
}
caption {
text-align:left;
font-weight:700;
margin-bottom:8px
}
th,td {
border:2px solid #8699b4;
padding:8px;
text-align:left
}
table {
border-collapse:separate;
border-spacing:4px 16px
}À remarquer : Le premier nombre règle l’écart horizontal ; le second règle l’écart vertical.
6. Six styles pour les mêmes données
Le HTML du tableau ne change pas. Chaque carte présente le CSS qui produit un résultat différent.
En-tête contrasté
<table>
<caption>Tarifs des ateliers</caption>
<thead>
<tr>
<th>Atelier</th>
<th>Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th>Découverte</th>
<td>Gratuit</td>
</tr>
<tr>
<th>Création</th>
<td>25 CHF</td>
</tr>
<tr>
<th>Expert</th>
<td>40 CHF</td>
</tr>
</tbody>
</table>table {
width:100%
}
caption {
text-align:left;
font-weight:700;
margin-bottom:8px
}
th,td {
border:2px solid #8699b4;
padding:8px;
text-align:left
}
table {
border-collapse:collapse
}
thead {
background:#253a70;
color:#fff
}À remarquer : La première ligne ressort grâce au fond et à la couleur du texte.
Lignes alternées
<table>
<caption>Tarifs des ateliers</caption>
<thead>
<tr>
<th>Atelier</th>
<th>Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th>Découverte</th>
<td>Gratuit</td>
</tr>
<tr>
<th>Création</th>
<td>25 CHF</td>
</tr>
<tr>
<th>Expert</th>
<td>40 CHF</td>
</tr>
</tbody>
</table>table {
width:100%
}
caption {
text-align:left;
font-weight:700;
margin-bottom:8px
}
th,td {
border:2px solid #8699b4;
padding:8px;
text-align:left
}
table {
border-collapse:collapse
}
tbody tr:nth-child(even) {
background:#edf0ff
}À remarquer : Une ligne sur deux reçoit un fond clair ; la lecture horizontale est plus facile.
Survol d’une ligne
<table>
<caption>Tarifs des ateliers</caption>
<thead>
<tr>
<th>Atelier</th>
<th>Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th>Découverte</th>
<td>Gratuit</td>
</tr>
<tr>
<th>Création</th>
<td>25 CHF</td>
</tr>
<tr>
<th>Expert</th>
<td>40 CHF</td>
</tr>
</tbody>
</table>table {
width:100%
}
caption {
text-align:left;
font-weight:700;
margin-bottom:8px
}
th,td {
border:2px solid #8699b4;
padding:8px;
text-align:left
}
table {
border-collapse:collapse
}
tbody tr:hover {
background:#bbf0e7;
outline:2px solid #18866f
}À remarquer : Passe la souris sur une ligne : seule la ligne pointée change. Le tableau reste compréhensible sans survol.
Prix alignés à droite
<table>
<caption>Tarifs des ateliers</caption>
<thead>
<tr>
<th>Atelier</th>
<th>Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th>Découverte</th>
<td>Gratuit</td>
</tr>
<tr>
<th>Création</th>
<td>25 CHF</td>
</tr>
<tr>
<th>Expert</th>
<td>40 CHF</td>
</tr>
</tbody>
</table>table {
width:100%
}
caption {
text-align:left;
font-weight:700;
margin-bottom:8px
}
th,td {
border:2px solid #8699b4;
padding:8px;
text-align:left
}
table {
border-collapse:collapse
}
td:last-child,th:last-child {
text-align:right;
font-variant-numeric:tabular-nums
}À remarquer : Les montants se comparent plus facilement quand leurs colonnes sont alignées.
Tableau compact
<table>
<caption>Tarifs des ateliers</caption>
<thead>
<tr>
<th>Atelier</th>
<th>Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th>Découverte</th>
<td>Gratuit</td>
</tr>
<tr>
<th>Création</th>
<td>25 CHF</td>
</tr>
<tr>
<th>Expert</th>
<td>40 CHF</td>
</tr>
</tbody>
</table>table {
width:100%;
border-collapse:collapse
}
th,td {
border:1px solid #9caec3;
padding:3px 6px;
text-align:left;
font-size:12px
}À remarquer : Un padding faible réduit la hauteur des lignes ; à utiliser seulement si le contenu reste lisible.
Tableau aéré
<table>
<caption>Tarifs des ateliers</caption>
<thead>
<tr>
<th>Atelier</th>
<th>Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th>Découverte</th>
<td>Gratuit</td>
</tr>
<tr>
<th>Création</th>
<td>25 CHF</td>
</tr>
<tr>
<th>Expert</th>
<td>40 CHF</td>
</tr>
</tbody>
</table>table {
width:100%;
border-collapse:collapse
}
th,td {
border:1px solid #9caec3;
padding:15px 18px;
text-align:left
}À remarquer : Un padding plus grand donne de l’air aux cellules, mais demande davantage de place.
7. Fusion, largeur et présentation
Ces exemples illustrent la structure HTML et quelques contraintes réelles de mise en page.
Cellules fusionnées visibles
<table>
<caption>Planning simplifié</caption>
<thead>
<tr>
<th>Jour</th>
<th>Matin</th>
<th>Après-midi</th>
</tr>
</thead>
<tbody>
<tr>
<th>Lundi</th>
<td colspan="2">Atelier HTML</td>
</tr>
<tr>
<th>Mardi</th>
<td rowspan="2">Projet CSS</td>
<td>Révision</td>
</tr>
<tr>
<th>Mercredi</th>
<td>Présentation</td>
</tr>
</tbody>
</table>table {
width:100%;
border-collapse:collapse
}
th,td {
border:2px solid #5e71aa;
padding:9px;
text-align:left
}
td[colspan],td[rowspan] {
background:#ddf4ee;
font-weight:700
}À remarquer : La cellule verte du lundi occupe deux colonnes. Celle de mardi s’étend sur deux lignes.
Légende sous le tableau
<table>
<caption>Tarifs des ateliers</caption>
<thead>
<tr>
<th>Atelier</th>
<th>Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th>Découverte</th>
<td>Gratuit</td>
</tr>
<tr>
<th>Création</th>
<td>25 CHF</td>
</tr>
<tr>
<th>Expert</th>
<td>40 CHF</td>
</tr>
</tbody>
</table>table {
width:100%
}
caption {
text-align:left;
font-weight:700;
margin-bottom:8px
}
th,td {
border:2px solid #8699b4;
padding:8px;
text-align:left
}
table {
border-collapse:collapse;
caption-side:bottom
}
caption {
padding-top:10px
}À remarquer : caption-side déplace la légende visuellement, mais elle reste liée au tableau.
En-tête et coins arrondis
<table>
<caption>Tarifs des ateliers</caption>
<thead>
<tr>
<th>Atelier</th>
<th>Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th>Découverte</th>
<td>Gratuit</td>
</tr>
<tr>
<th>Création</th>
<td>25 CHF</td>
</tr>
<tr>
<th>Expert</th>
<td>40 CHF</td>
</tr>
</tbody>
</table>table {
width:100%;
border-collapse:separate;
border-spacing:0;
border:1px solid #a7b7cc;
border-radius:12px;
overflow:hidden
}
th,td {
border:0;
border-bottom:1px solid #d6dfeb;
padding:10px
}
thead {
background:#dfe5ff
}À remarquer : Pour un tableau arrondi, separate et border-spacing:0 évitent certaines limites de collapse.
Tableau large avec défilement
<div class="tableScrollDemo">
<table>
<caption>Répartition des ateliers</caption>
<thead>
<tr>
<th>Atelier</th>
<th>Lundi</th>
<th>Mardi</th>
<th>Mercredi</th>
<th>Jeudi</th>
</tr>
</thead>
<tbody>
<tr>
<th>HTML</th>
<td>9 h</td>
<td>10 h</td>
<td>13 h</td>
<td>14 h</td>
</tr>
<tr>
<th>CSS</th>
<td>11 h</td>
<td>13 h</td>
<td>15 h</td>
<td>16 h</td>
</tr>
</tbody>
</table>
</div>.tableScrollDemo {
max-width:290px;
overflow-x:auto;
border:1px solid #9caec3
}
table {
min-width:640px;
border-collapse:collapse
}
th,td {
border:1px solid #9caec3;
padding:8px;
white-space:nowrap
}À remarquer : Fais défiler horizontalement à l’intérieur du cadre : aucune colonne n’est supprimée.
8. Trois modèles proches des exercices du cours
Les TP P4C1b et P4C1c travaillent la fusion d’en-têtes, les cellules sur plusieurs lignes, les totaux et les matchs annulés. Ces exemples utilisent d’autres données pour s’entraîner aux mêmes structures.
<table>
<caption>Stock du kiosque</caption>
<thead>
<tr>
<th>Produit</th>
<th>Prix</th>
<th>Quantité</th>
</tr>
</thead>
<tbody>
<tr>
<th>Carnet</th>
<td>4 CHF</td>
<td>12</td>
</tr>
<tr>
<th>Stylo</th>
<td>2 CHF</td>
<td>18</td>
</tr>
</tbody>
<tfoot>
<tr>
<th colspan="2">Quantité totale</th>
<td>30</td>
</tr>
</tfoot>
</table>Lundi occupe deux colonnes ; Projet CSS occupe deux lignes.
Le même tableau de produits peut être sobre ou plus marqué visuellement.
Stock : quadrillage simple
<table>
<caption>Stock du kiosque</caption>
<thead>
<tr>
<th>Produit</th>
<th>Prix</th>
<th>Quantité</th>
</tr>
</thead>
<tbody>
<tr>
<th>Carnet</th>
<td>4 CHF</td>
<td>12</td>
</tr>
<tr>
<th>Stylo</th>
<td>2 CHF</td>
<td>18</td>
</tr>
</tbody>
<tfoot>
<tr>
<th colspan="2">Quantité totale</th>
<td>30</td>
</tr>
</tfoot>
</table>table {
width:100%;
border-collapse:collapse
}
th,td {
border:1px solid #93a3b9;
padding:8px;
text-align:left
}
tfoot {
font-weight:700
}À remarquer : Le tfoot rassemble le total ; colspan fusionne les deux premières colonnes.
Stock : en-tête et total colorés
<table>
<caption>Stock du kiosque</caption>
<thead>
<tr>
<th>Produit</th>
<th>Prix</th>
<th>Quantité</th>
</tr>
</thead>
<tbody>
<tr>
<th>Carnet</th>
<td>4 CHF</td>
<td>12</td>
</tr>
<tr>
<th>Stylo</th>
<td>2 CHF</td>
<td>18</td>
</tr>
</tbody>
<tfoot>
<tr>
<th colspan="2">Quantité totale</th>
<td>30</td>
</tr>
</tfoot>
</table>table {
width:100%;
border-collapse:collapse
}
th,td {
border:1px solid #93a3b9;
padding:9px;
text-align:left
}
thead {
background:#dfe5ff
}
tfoot {
background:#d8f3ea;
font-weight:700
}À remarquer : La structure HTML est identique ; seules les couleurs attirent l’attention sur l’en-tête et le total.
Sport : match annulé
<table>
<caption>Tournoi scolaire</caption>
<thead>
<tr>
<th>Équipe A</th>
<th>Équipe B</th>
<th>Score</th>
<th>Terrain</th>
</tr>
</thead>
<tbody>
<tr>
<th rowspan="2">Lynx</th>
<td>Faucons</td>
<td>2–1</td>
<td>A</td>
</tr>
<tr>
<td>Renards</td>
<td>1–1</td>
<td>B</td>
</tr>
<tr>
<th>Ours</th>
<td>Loups</td>
<td colspan="2">Match annulé</td>
</tr>
</tbody>
</table>table {
width:100%;
border-collapse:collapse
}
th,td {
border:1px solid #93a3b9;
padding:8px;
text-align:left
}
td[colspan] {
background:#fff1df;
font-weight:700
}À remarquer : La cellule « Match annulé » occupe à la fois les colonnes Score et Terrain ; Lynx occupe deux lignes.
9. Fusionner un en-tête et une donnée
L’exercice P4C1b combine un en-tête colspan et une donnée rowspan. Dans la seconde ligne de Suisse, il n’y a pas de troisième td : la cellule de la ligne précédente l’occupe déjà.
Deux formes de fusion
<table class="passagersDemo">
<caption>Participants au trajet</caption>
<thead>
<tr>
<th colspan="2">Identité</th>
<th scope="col">Pays</th>
</tr>
<tr>
<th scope="col">Nom</th>
<th scope="col">Âge</th>
<th scope="col">Origine</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Nora</th>
<td>24 ans</td>
<td rowspan="2">Suisse</td>
</tr>
<tr>
<th scope="row">Milan</th>
<td>31 ans</td>
</tr>
<tr>
<th scope="row">Iris</th>
<td>28 ans</td>
<td>France</td>
</tr>
</tbody>
</table>.passagersDemo {
width:100%;
border-collapse:collapse
}
.passagersDemo caption {
padding:8px;
text-align:left;
font-weight:700
}
.passagersDemo th,.passagersDemo td {
border:1px solid #637ca5;
padding:9px;
text-align:left
}
.passagersDemo thead {
background:#dfe8fa
}
.passagersDemo td[rowspan] {
background:#d4f3e9
}À remarquer : Identité couvre deux colonnes ; Suisse couvre deux lignes. La grille garde trois colonnes sur chaque ligne.
10. Mettre en évidence une cellule précise
Dans le TP CyberSafe, un état particulier doit ressortir. Une classe sur la cellule concernée est plus précise qu’une règle sur toute la ligne. Le texte de l’état reste présent pour que la couleur ne porte pas l’information seule.
Tableau de suivi avec total
<table class="auditDemo">
<caption>Contrôles du laboratoire</caption>
<thead>
<tr>
<th scope="col">Zone</th>
<th scope="col">État</th>
<th scope="col">Priorité</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Accueil</th>
<td>Terminé</td>
<td>Normale</td>
</tr>
<tr>
<th scope="row">Connexion</th>
<td class="enCours">En cours</td>
<td>Haute</td>
</tr>
<tr>
<th scope="row">Archives</th>
<td>À vérifier</td>
<td>Normale</td>
</tr>
</tbody>
<tfoot>
<tr>
<th colspan="2" scope="row">Zones suivies</th>
<td>3</td>
</tr>
</tfoot>
</table>.auditDemo {
width:90%;
margin:auto;
border-collapse:collapse;
box-shadow:0 4px 14px #17384922
}
.auditDemo caption {
caption-side:top;
padding:9px;
text-align:left;
font-weight:700
}
.auditDemo th,.auditDemo td {
border:1px solid #1a4d6e;
padding:10px;
text-align:left
}
.auditDemo thead {
background:#e6edf2;
color:#1a4d6e
}
.auditDemo .enCours {
background:#e0f3f6;
font-weight:700
}
.auditDemo tfoot {
background:#edf1fa
}À remarquer : margin: auto centre le tableau de largeur limitée ; border-collapse colle les bordures ; la classe enCours cible une seule cellule.
11. Vérifier le nombre de colonnes
Avant de styliser un tableau complexe, dessine ses cases. Si la première ligne possède quatre colonnes, chaque ligne du corps doit aussi en occuper quatre, en comptant les cellules couvertes par colspan ou rowspan.
| Ligne | Cellules écrites | Colonnes réellement occupées |
|---|---|---|
| En-tête | 1 cellule de largeur 2 + 2 cellules simples | 4 |
| Première donnée | 1 cellule de hauteur 2 + 3 cellules simples | 4 |
| Deuxième donnée | 3 cellules simples | 4, car la fusion de la ligne précédente occupe la première |
12. Lire le HTML et le CSS d’un tableau
Lis d’abord les lignes et leurs en-têtes, puis observe ce que border-collapse change sur les bordures.
En lien avec : TP P4C1, P4C1b et P4C1c tableaux.
Petit tableau de prix
<table class="tableLecture">
<caption>Ateliers</caption>
<thead>
<tr>
<th scope="col">Nom</th>
<th scope="col">Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Découverte</th>
<td>Gratuit</td>
</tr>
<tr>
<th scope="row">Création</th>
<td>25 CHF</td>
</tr>
</tbody>
</table>.tableLecture { width: 100%; border-collapse: collapse; }
.tableLecture th, .tableLecture td { border: 2px solid #557a91; padding: 9px; text-align: left; }
.tableLecture thead { background: #dceef2; }À remarquer : Les bordures voisines fusionnent en un seul trait.
Lire le code dans l’ordre
captionnomme le tableau ;thdésigne les en-têtes.scope="col"etscope="row"précisent la direction de chaque en-tête.border-collapse: collapsefusionne les bordures qui se touchent.paddinglaisse de l’espace entre le texte et les traits.
13. Défi minute : fusionner les bordures
En lien avec : TP P4C1, P4C1b et P4C1c tableaux.
À faire : Ajoute une légende et des en-têtes compréhensibles, puis affiche une seule bordure entre les cellules.
<table class="tarifsDefi">
<tr>
<td>Atelier</td>
<td>Prix</td>
</tr>
<tr>
<td>Découverte</td>
<td>Gratuit</td>
</tr>
</table>.tarifsDefi th, .tarifsDefi td {
border: 1px solid #4d7794;
padding: 8px;
}Indice
Utilise caption, th scope="col", th scope="row" et border-collapse: collapse.
Voir la correction et le rendu
Le tableau porte la règle de fusion ; chaque cellule garde une bordure définie par th, td.
<table class="tarifsDefi">
<caption>Tarifs</caption>
<thead>
<tr>
<th scope="col">Atelier</th>
<th scope="col">Prix</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Découverte</th>
<td>Gratuit</td>
</tr>
</tbody>
</table>.tarifsDefi {
width: 100%;
border-collapse: collapse;
}
.tarifsDefi th, .tarifsDefi td {
border: 1px solid #4d7794;
padding: 8px;
text-align: left;
}
.tarifsDefi thead {
background: #e2eef4;
}- La légende nomme les données.
- Les en-têtes indiquent leur direction.
- Les traits voisins ne sont plus doublés.