Html – Is this syntatically valid for div

xhtml

<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 ? */

Best Solution

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.