Wandering Thoughts archives


CSS separates layout from content less than you'd like

It is generally an article of faith that once you switch to (properly done) CSS, you can do significant layout changes without having to change your content. Unfortunately I believe that this is somewhat of a myth in practice.

In practice, what you can do with CSS alone is limited to how your content is structured and tagged with things like CSS classes and ids. And the problem is that generally, people do not obsessively structure and tag their content; they mark it up and tag it for what their CSS currently needs, with a side helping of tagging for changes they think they might want to make in the future.

(This shouldn't surprise anyone, since people strongly resist doing extra work that seems (at the time) unlikely to ever be used. In fact, obsessively creating tagged markup that you don't see a need for is really a case of premature optimization.)

Thus on most sites there are fairly strong limits on what can be done with CSS changes alone; going beyond this needs some content changes. If you're in luck, all you need is for existing structures to be tagged so you can yank them around. If you're unlucky, you need structural changes that add new <div>s or <span>s.

In other words, what you get from CSS in practice is that it is easier to make layout changes that you were already thinking about (and thus built hooks for into your content). This is not a bad thing, but it is far from the panacea that common CSS folklore makes it out to be.

(The way to test this is not to look at example sites, but to get something like Stylish and wander around trying to make changes to random sites with CSS-based layouts.)

web/CSSLayoutSeparation written at 23:24:18; Add Comment

Page tools: See As Normal.
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.