Skip to: content, navigation

xml:space (HTML attribute)

Spec
Depr. Version
No XHTML 1.0

Syntax

xml:space="preserve"

Description

If the formatting and alignment of your CSS markup is incredibly important to you, you can use the xml:space attribute in XHTML 1.0 documents to ensure that whitespace isn’t collapsed or removed according to the rules defined in the XHTML modularization guidelines. In XHTML 1.0 recommendation, the value is currently fixed as "preserve", so there’s no way not to preserve whitespace in XHTML.

Example

The script whitespace is set to "preserve" in XHTML 1.0 using xml:space value of "preserve":

<style type="text/css" xml:space="preserve">
  #nav      {color:red;}
  #logo     {color:lime;}
  #branding {color:black;}
</style>

Value

The only value that xml:space can take 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

Search