White space inside XML/HTML tags

The specification (section 3.1 Start-tags, end-tags, and empty-element tags) says that there is no white space between the '<' and the tag name, between '</' and the tag name, or inside '/>'. You can add white space after the tag name, though:

<foo            >
</foo        >
<bar
/>

</ and /> are tokens, so whitespace between the two characters would be a syntax error. And as Guffa pointed out, whitespace isn't allowed between the opening token and the name. But you're fine adding whitespace between the element tag and the closing >(or />) token.

EDIT to reflect Guffa's correct citing of the XML specification.


The HTML[5] standard appears to agree exactly with the XML standard, as described by Guffa...

http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#start-tags