<div class='clear'></div>
/*which comes out to be below one in FF (seen via firebug) */
<div class='clear'/>
/*is this the last empty div declaration is semantically valid ? */
views:
144answers:
7A DIV is a block level container. The second example can't contain anything... so my bet would be no (for an HTML4 doctype)
If you want to use a dummy element for clearing purposes - have you considered <br />
?
Edit
There are more effective ways of clearing than using using a block level container. Applying a clear class to <br />
is one example - but 'overflow: hidden' on the parent element is usually much more elegant.
If you're asking if those two tags are equivalent and valid: yes, yes they are.
See this question for practical considerations.
Whether this is valid or not depends on the DOCTYPE of the document you are writing. I would suggest to get a definitive answer you try the here:
<div class='clear'></div>
and
<div class='clear'/>
both are same. Though i prefer former one over the later.
In XHTML, the construct is valid (and identically equivalent to your original source) but not HTML compatible.
HTML compatibility doesn't matter when it comes to viewing a representation of the DOM as seen by the browser. It does matter when writing markup.
As an aside, adding empty elements purely for styling purposes is ugly and should be avoided if possible. See http://www.ejeliot.com/blog/59 for some alternative methods for containing floats.