No skin off my nose: why CMS systems should be good to CSS authors

I’ve just had a bad experience attempting to provide the cascading stylesheet (CSS) for a design to go onto the HTML generated by a content management system (CMS).

The reason my work wasn’t good is probably that, early on, the poor quality of the HTML structure generated by the CMS had made me decide not to be methodical. I ggve up on the idea of comparing several similar pages to find a common origin from which to derive my CSS rules; instead I dived into the DOM inspector, going a short way up the element tree, making up a rule, quickly comparing a few pages to assess the effect, and moving on.

The client told me later that thought this approach wasted a lot of time. In hindsight I have to agree, though as new pages with different layouts of similar content were being created while I worked it is not entirely surprising.

What I think it shows is this. When HTML trees are deep, and when they may vary in the elements and classes all the way up to the top containing elements, it is naturally a lot of work for a CSS author to identify common elements that can be relied on to construct rules which will efficiently capture all the right structures and no others. If the CSS author cannot identify those elements quickly, they will soon lose trust in the HTML structure. When that happens, they will resort to ‘trial-and-error’ methods, knowing that CMSes like other automated systems often generate impenetrable HTML.

When that happens, the result is poor-quality CSS. Typically, it has unnecessarily duplicated rules. It is long and badly organised. It sacrifices elegance and expressiveness just to get the job done. All these things make it likely to work badly (failing to support all the layouts across different rendering engines) and unpleasant to maintain. This is not good for any developer’s reputation and it is unlikely to make them enthusiastic about working with the CMS. To thrive in the marketplace, a CMS relies on being liked by its developer community.

So CMSes can help not only their code smell but their reputations if they keep their document structures tidy. This is of course a very old chestnut. HTML5 helps the CMS authors to do better work by replacing vague class names like ‘main-content’ with elements like <article> which clearly signal what they are for. In turn, CSS authors can pick up the clear signals and work efficiently to produce good code of their own.

As content management systems have a habit of sticking around for a few years, making the HTML tidy and keeping it tidy is something to do now for a brighter future.

Published on 20/09/2011 at 05:30 by Technophile, tags , , ,

If you liked this article you can add me to Twitter

comment No skin off my nose: why CMS systems should be good to CSS authors

Trackbacks are disabled

Powered by Publify – Thème Frédéric de Villamil | Photo Glenn