xml:space (HTML attribute)

Spec
Depr. Version
No XHTML 1.0

Syntax

xml:space="preserve"

Description

If the xml:space attribute with the value "preserve" is applied to the script element, the user agent (that is, the browser) must leave all whitespace characters intact, with the exception of leading and trailing whitespace characters, which should be removed. Otherwise, whitespace will be collapsed according to the rules defined in the XHTML modularization guidelines (to provide a much simplified summary, duplicate or unnecessary white spaces are removed). Currently, in XHTML 1.0, the value is fixed as "preserve", so there’s no way not to preserve whitespace in XHTML.

Example

This script element’s whitespace set to "preserve" in XHTML 1.0:

<script type="text/javascript" src="/scripts/complex.js"
    xml:space="preserve"></script>

Value

The only value the xml:space attribute accepts is "preserve".

User-contributed notes

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products