First published 23 december 2006
- Good way
colspan="2" style="text-align:center"
- Better way
td[colspan] {text-align:center}
The first method uses inline CSS, which is considered suboptimal (hard to maintain, bigger code…). The second one uses the conditional styling feature of CSS: is a td
tag contains a colspan
attribute (whatever is its value), then the content should be centered.
For more information on this, check the free Chapter 2 of Cascading Style Sheets: The Definitive Guide, Second Edition.
If you like these kind of very concise recipes, take a look at CSS code recipes.
Aucun commentaire:
Enregistrer un commentaire