Why <div style="width:50%" />
is not rendered in xHTML?
If I do <div style="width:50%"> </div>
only then it is rendered. Do I miss something?
Will min-width help?
I use strict xHTML 1.0
Is it possible to fix it with CSS only or I must change html markup?
Because DIV
is not a self-closing element in either XHTML or HTML.
You must pair the opening tag (<div>
) with the closing (</div>
) .
On the other part of your question:
<div style="width:50%"> </div>
<div style="width:50%"></div>
The difference between is that in the first there is a non-breaking space character that fills up the DIV
. In the second there is nothing. That is why you will not see anything render on the second version.
Also, XML and XHTML are not the same thing. The latter borrows the convention of self-closing a tag if it's not part of a matching pair.