Click to See Complete Forum and Search --> : clearing tag instead of clearing div


bobsawey
06-22-2009, 03:13 PM
Hey folks,

I'm looking for some feedback on this.

I've been thinking of doing something like <clear /> instead of <div class="clear-both">

Any idea why I shouldn't make a new tag for this? It would make for more clean code, and I don't see why it's off standard since it honors xml and can be styled with css.

Thanks!

-Bob

WebWarrior
06-22-2009, 05:31 PM
The clear is a CSS property used to clear floats (another CSS property). It doesn't really have much to do with XHTML. I've seen a few times developers overusing <div class="clear"></div> or a slightly better (in my opinion) br { clear: both; } then just use <br /> in your code. Most of the time you simply use float on all of your page's elements and attach the clear property to the page's footer or the following non-floating element. Either way, it is probably better if handled in CSS. Using <div id="clear"></div> or even <clear></clear> would add too much additional markup to your XHTML code.

Shorts
06-22-2009, 05:45 PM
This is what I've started using on the site I work for (which used to abuse <div class="clear_both"></div>):

http://www.positioniseverything.net/easyclearing.html

The container element gets a class clear_fix (or has similar coding), so no additional HTML elements on your page. That with other clean ups got the index page from an initial 1880+ elements! down to ~475 elements (and ~800 if all tabs are hover overed).

Check it out, it's a cool like CSS nugget to have. (btw http://www.talenttrove.com/ is where I'm working)