Propriété captionSidede Style
Objet Style
Définition et utilisation
La propriété captionSide définit ou renvoie la position de la légende du tableau.
Syntaxe
Définir la propriété captionSide :
Object.style.captionSide="top|bottom|inherit"
Renvoie la propriété captionSide :
Object.style.captionSide
| Valeur | Description |
|---|---|
| top | Par défaut. Positionne la légende du tableau au-dessus du tableau. |
| bottom | Positionne la légende du tableau en dessous du tableau. |
| inherit | La valeur de la propriété captionSide est héritée de l'élément parent. |
Prise en charge des navigateurs
![]()
![]()
![]()
![]()
![]()
Tous les principaux navigateurs prennent en charge la propriété captionSide.
Remarque :IE7 et les versions antérieures ne prennent pas en charge la propriété captionSide. IE8 prend en charge la propriété captionSide uniquement lorsqu'un !DOCTYPE est déclaré. IE9 prend en charge la propriété captionSide.
Exemple
Exemple
Déplacer la légende du tableau vers le bas du tableau :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutoriel d'exemple (example.com)</title>
<script>
function displayResult(){
document.getElementById("myCap").style.captionSide="bottom";
}
</script>
</head>
<body>
<table border="1">
<caption id="myCap">Mes économies</caption>
<tr>
<th>Mois</th>
<th>Épargne</th>
</tr>
<tr>
<td>Janvier</td>
<td>$100</td>
</tr>
<tr>
<td>Février</td>
<td>$150</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">Déplacer la légende du tableau</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Tutoriel d'exemple (example.com)</title>
<script>
function displayResult(){
document.getElementById("myCap").style.captionSide="bottom";
}
</script>
</head>
<body>
<table border="1">
<caption id="myCap">Mes économies</caption>
<tr>
<th>Mois</th>
<th>Épargne</th>
</tr>
<tr>
<td>Janvier</td>
<td>$100</td>
</tr>
<tr>
<td>Février</td>
<td>$150</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">Déplacer la légende du tableau</button>
</body>
</html>
Essayez-le vous-même »
Objet Style Autres extensions