View Full Version : div & span: theoretical question

01-29-2004, 08:56 PM
Here's an HTML/CSS issue I'm struggling with: I pretty much use <div> and <span> solely for style purposes. I may have some DIVs and SPANs in my markup, prior to worrying about style. By the time I've implemented my style, though, I have added many additional DIV and SPAN elements. They're there solely for the design.

For example, this design has five nested DIVs:http://muledesign.hoologic.com/hmm.html

Or, let's say you want to display a word, and have the font size of each successive letter to increase by one. You'd have a ton of nested SPANs that have nothing to do with the content.

Is this just the way things work? Do purists never add additional DIV or SPAN tags beyond what is needed to properly define the document's content?

01-29-2004, 09:17 PM
Sadly, there is no other alternative currently. You have to introduce an element for each thing you want to style. Even worse, because iew doesn't support CSS2, CSS3 even less, we have to give each element it's own id or class. A real purist would probably still introduce an element each, but not give them any class or id, unless he intended to use the styles for each letter multipler times in the document, and maybe not even then, if the situations were similar enough.

01-30-2004, 04:44 PM
Maybe it makes sense to use <DIV> and <SPAN> (uppercase) for elements that are being added strictly for stylistic purposes, and use <div> and <span> (lowercase) for those that are being used for actual content markup? Or vice-versa, of course.

01-30-2004, 04:55 PM
Purists use lowercase - since XML is case sensitive and purists use XML.

OH, and remember that the structure must be there for the style to be able to add presentation to it. There's no real reason why you SHOULDN'T add structure it it's going to be used for something. It's just that we think that the structure should be be describing the document or preferably the content, instead of being there for presentational reasons only.