XHTML space slash

XHTML tags in the format <tag />.

<br />, <hr />, <img />, <input />, <base />, <link />

The space before closing slash was primarily done for legacy browsers that did not properly parse the value without an attribute or space, but does have some value in improving readability of XHTML markup. (In my experience this is NN4.x and earlier.)

Per http://www.w3.org/TR/xhtml1/#C_2:

C.2. Empty Elements

Include a space before the trailing / and > of empty elements, e.g. <br />, <hr /> and <img src="karen.jpg" alt="Karen" />. Also, use the minimized tag syntax for empty elements, e.g. <br />, as the alternative syntax <br /> allowed by XML gives uncertain results in many existing user agents.

REFERENCE:

Leave a Reply