In his book, Transcending CSS: The Fine Art of Web Design, author Andy Clarke argues in favor of content-out markup. This approach centers around defining the content on the page in a semantic way that makes sense to those using browsers without style information. The base XHTML should be as free of layout coding as possible, even to the point of following a different flow. Then, CSS should be used to create the layout on top of it, using absolute positioning to break the XHTML elements from their flow as necessary.
That CSS should be the predominant source for layout and other style information is undeniable; I agree with Clarke wholeheartedly. Where I think he errs is his abandonment of floats for absolute positioning. While acknowledging that floats are, “almost a de facto standard method for creating column layouts using CSS,” he argues that they are too fragile. He’s right, of course; floats can unintentionally clear when they’re not supposed to because they happen to be one pixel too wide. “Whereas float-dependent layouts can easily fall apart at the slightest nudge,” Clarke asserts, “positioned layouts can support supersized images or gigantic text without failing.”
This dependency alone makes me question the original argument. Float-based layouts are prone to falling apart when their content exceeds width limitations, while position-based layouts are not. Furthermore, float-based layouts must conform to a source order resembling the layout order, while position-based layouts have no such requirement.
It’s clearly a trade-off. If we stick to floats for layout, we must be cautious to restrict content width accordingly. This requires added diligence, but, given the proliferation of float-based layouts on the internet, I think people have readily accepted the challenge. Besides, if we have “supersized images or gigantic text” on our pages, the fact that they are breaking our design only adds insult to injury; we’re going to want to correct the problem whether the design fails gracefully or not.
I’m not trying to be pretentious; I know I’m not half the designer Clarke is. However, much as I’ve learned from his book, I don’t think I’m ready to abandon float-based layouts just yet. Every approach to web design has its strengths and weaknesses. In this case, however, I don’t find Clarke’s arguments in favor of position-based layouts all that convincing.