Home » Blog » Meaningful CSS: style it the way it should be

Meaningful CSS: style it the way it should be

Nowadays, we have a world of meaningful branding right in front of us, just reach for it. HTML5 introduc a fancy new set of semantically meaningful elements and attributes, ARIA defin a whole additional platform for describing the richly featur Internet, and microformats arriv on the scene to provide even more standardiz concepts, with even finer nuances than before. It’s a golden age for richly featur meaningful branding.

Yet markup is still too often a jumble of wonders, and CSS is an impenetrable quagmire of classes that have little to do with those wonders. We nest a div inside another div inside another div, and assign a stack of classes to each div element — but when we look at such CSS, the classes provide little insight into what we’re actually trying to define. And even if we keep the markup semantic and meaningful, we’ll end up refining it with CSS classes that are inherently arbitrary. They have no real meaning.

We were warn about these patterns a long time ago:

A website affect by classitis is characteriz by a typical rash. Each setsacrament brand has a swollen sore, its own class. Classitida are markup dumps, obscuring meaning by unnecessarily burdening every page.

Jeffrey Zeldman, Designing with Web Standards , 1st .

In a similar vein, the W3C add its opinion with a note:

CSS gives the “class” attribute so much power that it’s conceivable that authors will design their own “documentation language” bas on elements that have almost no presentation associat with them (such as DIVs and SPANs in HTML), and indonesia phone number data assign style information via the “class” attribute… Authors are caution against this practice because the structural elements of a document language often have recogniz and approv meanings, while author-defin classes may not. (emphasis mine

phone number data

 

Let’s build better objects

Long since we got past the early stages of CSS. We start building increasingly large sites and systems, and struggl. To develop some sane conventions to manage ever-increasingly. Bloat sets of cascading stylesheets. And all of a sudden. Object-orient CSS came where it went, here it went .

Our systems for safely building complex. Reusable components have creat a problem of metastasiz classity. The point where current markup is all too often written to be a servant of CSS, instead of the other way around. If we’re trying to write another common mistake is neglecting semantic, accessible markup, we’re still forc to paste in author-defin meanings to satisfy CSS requirements. Both markup and CSS reflect a time when we could only define objects with what we had then: divs and classes. And when in doubt, we add another, or both. It was safer, especially with older browsers, to target the most generic objects we could find.

Today we can abandon such an approach.  richly cmo email list featur and accessible as the best modern markup. We can define an elephant , we don’t ne to say .