views:

38

answers:

2

Hello.

I've been experimenting with xhtml and now I'm wondering that is there a valid/correct way to add empty elements.

Short question, but here's the two ways I've been using:

<div> </div>
<div>&#32;</div> <!-- Same as space -->

Hope someone knows an answer for this.

Thanks.

+3  A: 

Like this:

<div></div>

A space inside an element is not "nothing" - it's a text node which makes the element non-empty.

nickf
A: 
<div />

is valid XTHML for an empty element: i.e. self-closing. Same as

<div></div>
carillonator
Okay, thanks :-) This is actually the thing I was looking for.
Martti Laine