Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Since most tables are generated programmatically these days, it's probably easier just to use classes for this kind of styling. And it seems a lot of people forget about the <colgroup> HTML element, which makes it easy to style columns without adding classes to every table cell.


It's probably even easier to just put inline styles on every row, but neither of those practices are going to result in maintainable markup.

By adding classes for the singular purpose of styling them, you tie your markup to the appearance of the web page. Instead, classes should be used to further describe the contents of elements in relation to each other. Then all the presentational rules can be kept in CSS, and selectors can be used to style based on the meaning of the content.

This means the style of the page can change without modifying the markup. And if the styles are written well enough, they can be applied to any (sane) markup.

Oh and +1 for colgroup!


I agree that classes are the best bet. In terms of colgroup, the one issue is that it won't work if you're using colspan on only a subset of your rows.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: