Although a self-closing <div />
should generally be avoided in XHTML (because it won't parse as expected in legacy HTML browsers), this is not actually anything to do with XHTML: it's a layout issue.
<div></div>
is a block element containing no content. Its height is therefore zero; you can't see it.
<div> </div>
is a block element containing one line of text. Its height is equal to the line-height
property.
If you want an empty div to have some height, you must say so:
<div style="width: 50%; height: 2em; background: red;"></div>
It is an old IE5 bug that an empty div would still render with height as if it contained a line of text. When you are using a Standards Mode doctype (which you should be regardless of whether you are using HTML or XHTML, Transitional or Strict), you won't see this behaviour.