Personally, I don’t consider it to be “divitis” if tags are added as NECESSARY hooks for CSS with goals of: achieving a CSS effect, cross browser compatibility ( it would all be simpler if IE had played nice from the begging), and proper validation.
A simplified example, in a “menu” list with sliding door effect buttons the simplest correct way SHOULD have been : <li><a href=“#”>item</a></li>, where part oft he css would be applied to the LI the rest to the A , thus utilizing every tag and not adding code for the sake of effect. However, IE versions would not like this; we could then theorize that the could could still be kept minimal , sensible , and “somewhat” semantic :<a href=“#”><li>item</li></a>. This, of course, will not validate. so we are left with only with the choice to add the extra tag and get : <li><a href=“#”><span>item</span></a></li>. It IS undeniably mark up for the sake of style… but there is no other way of doing it… thus why I dont call it “divitis”.
OK, that was pretty straight forward. but there are “gray situations” in which I cant tell if it’s my noobie skills, or if have once more been back into a corner.
Example 1:
I think clearfix css is the most brilliant CSS idea known to man. In a list with floated items, it would have been great to take care of it all with CSS with something like UL:after{ display:block; content:“”; clear:both} or such. Unfortunately it doesn’t work with IE (earlier than IE8, at least so IE still guilty). So I have been using a <span class=“clearer”> after the last <LI> where .clearer{display:block; clear:both}. Ok, I added an extra tag for the sake of IE. I hope Bill is happy. BUT WAIT… this doesnt validate ( not to mention it messes up something serious if you provide ti as a component for a client who useas a WYSIWYG editor that doesn’t close the LI tags… damn… and what do you know, validation DOES serve a purpose)
It doesn’t validate or work, because the UL expects only LI as children. There is another option ( manually find the last LI in each list and add a class to stop/clear the float…), but this is very clumsy an in essence adding TRULLY linking style to content; at least with the span method you could alter the list back and forth and not worry about affecting the layout.
So, since the UL is GOING to collapse, am left with the choice to add another (div) tag as a wrapper, migrate the style from the UL to the wrapper, and move the clearing span outside the UL. You have added 2 extra tags now, and cant even get the added benefit of having the look of the container being “sliding door expandable” since the UL box is collapsed, thus essentially useless…
Am I missing a better practice out there? Or is this a normal compromise to make?
Similarly, let say you wanted to do some simple list typography. you want the bullet outside a list so that it doesn’t indent the text in the list item, when you hover over the list item you want the background to change color, maybe have a fade… simple … except that since the bullet is out side the LI the background doesn’t include it. The way I have achieved this effect is to have list-style:none and wrap extra tags again for multiple bg images, as such:
<li><a href=“#”><span>item</span></a></li>
the <A> is mostly for IE :hover, but it also holds a non repeating bullet image… I will admit bg images are easier to control that bullets… but an extra tag for this???
<span> would have the indent (padding-left) for the text and the background color and image.
so essentially, two tags again used as hooks for css… is it divitis? Or am I ok?