English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The align attribute specifies the horizontal alignment of the content related to the col element, the <col> tag specifies column properties for each column within the <colgroup> element, and the <col> tag is very useful for applying styles to the entire column rather than repeating styles for each cell in each row.
Use <colgroup> and <col> tags to set the background color of three columns:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Use of HTML <col> align attribute-Basic Tutorial(oldtoolbag.com)</title> <style>table, th, td { border: 1px solid black;</style> </head> <body> <table> <colgroup> <col span="2" style="background-color:red"> <col style="background-color:yellow"> </colgroup> <tr> <th>ISBN</th> <th>Title</th> <th>Price</th> </tr> <tr> <td>3476896</td> <td>My first HTML</td> <td>$53</td> </tr> <tr> <td>5869207</td> <td>My first CSS</td> <td>$49</td> </tr> </table> </body> </html>Test to see ‹/›
IEFirefoxOperaChromeSafari
Seuls Opera et Internet Explorer 8 et les versions d'IE plus anciennes prennent en charge l'attribut align (IE9L'attribut n'est pas pris en charge).
HTML5 L'attribut align de la balise <col> n'est pas pris en charge.
L'attribut align détermine la manière dont le contenu associé à l'élément col est aligné horizontalement.
La balise <col> spécifie les attributs de colonne pour chaque colonne de l'élément <colgroup>.
La balise <col> est très utile pour appliquer un style à toute la colonne, plutôt que de répéter le style pour chaque cellule de chaque ligne.
<col align="left|right|center|justify|char">
Valeur | Description |
---|---|
gauche | Aligner le contenu à gauche (valeur par défaut). |
droite | Aligner le contenu à droite. |
centrer | Centrer le contenu (valeur par défaut de l'élément th). |
justifier | Étendre les lignes de manière à ce que chaque ligne ait une longueur égale (comme dans les journaux et les magazines). |
caractère | Aligner le contenu sur le caractère spécifié. |