Rounin Rounin - 1 year ago 68
HTML Question

HTML's handling of white-space characters depends on context - but what are the rules?

The Unicode catalogue includes a number of white-space characters, some of which don't appear to work in any context in HTML documents - but some of which, rather usefully, do.

Here is an example:

<h1 title="Hi! As a title attribute, &#013;I can contain &#009;&#009;horizontal tabs &#013;and carriage returns &#010;and line feeds.">HTML's handling of &amp;009; | &amp;010; | &amp;013;</h1>

<p>Hello. As a paragraph element, I can't contain &#009;horizontal tabs &#013;or carriage returns &#010;or line feeds.</p>

<input type="submit" value="I am a value attribute and &#010;like title I can also handle line feeds" /><br />

<input type="submit" value="I am another value attribute. &#009;&#009;Like title I can handle horizontal tabs" /><br />

<input type="submit" value="I am a third value attribute. &#013;Unlike title I can't handle carriage returns" />

Is there any official spec or series of guidelines which detail which white-space characters can be deployed in HTML documents and where?

Answer Source

It's a little unclear what you mean by work, but I'm going to assume you mean rendering, at which point what happens is really up to CSS. defines how most whitespace characters are normalized away, unless you adjust the white-space property.

Note that the display of toolbars (such as from the title attribute) and form controls (such as from input elements) is not defined by any standard, leaving that effectively up to browsers.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download