Why not to use CSS for columnar layoutsFri, Nov 25, 2005 in Web
DIV tags and CSS to format a single text into multiple columns is just as bad as using tables for layout. This article explains why.
Everyone agrees tables are not for layout, because tables are supposed to contain tabular data. Similarly,
DIV elements aren’t the right tool for columns, because they are supposed to group content into a generic container – either to group related elements simply for grouping’s sake, or to identify actual content and apply meta-data such as language or class. From the spec:
SPANelements, in conjunction with the
classattributes, offer a generic mechanism for adding structure to documents. The keyword is structure. Using
DIVelements to lay out text into columns isn’t structural, it’s presentational. Consider how columnar text is typically accomplished:
DIVelements, floated left so they’ll stack next to each other. This is not semantically meaningful! In particular, the text must be split into multiple
DIVs to get it into columns. Now the text, which is one piece of content and should not be divided, has been divided as though it’s many pieces of content.
Many people don’t like to admit it, taking a sort of “end justifies the means” attitude and forcing the content into columns with hacks, but HTML and CSS currently provide no mechanism for presenting a single text in multiple columns (CSS 3, which is not finalized, will provide a mechanism, and beta versions of Firefox currently support it). What bothers me the most about the hacks is those who approve of and admire them. Violating standards is nothing to be happy about or advocate. Those who do so are certainly not on the cutting edge. The cutting edge is about semantics and standards, not about ignoring semantics and violating standards.
DIVs) is that the content is in a single
For purists though, there’s no getting around it until CSS 3: anything you do to format a single text into multiple columns is a hack, also known as an abuse. How quick we are to criticize people who used tables for layout, but how soon we forget our high-minded principles when we can’t have what we want.
About The Author
Baron is the founder and CEO of VividCortex. He is the author of High Performance MySQL and many open-source tools for performance analysis, monitoring, and system administration. Baron contributes to various database communities such as Oracle, PostgreSQL, Redis and MongoDB.