Skip to: content, navigation

by Ian Lloyd

xml:space (HTML attribute)

Spec
Depr. Version
No XHTML 1.0
xml:space="preserve"

Example

The script white spaces set to "preserve" in XHTML 1.0:

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

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 is not collapsed/removed according to the rules defined in XHTML modularization.

Value

"preserve" only (to not preserve whitespace, simply omit attribute)

Compatibility

User-contributed notes

ID:
#1
Date:
Wed, 12 Mar 2008 08:57:11 GMT
Contributed by:
AutisticCuckoo

You can't make a UA not preserve whitespace by omitting this attribute, since it's declared as #FIXED with a value of "preserve".

In theory, a UA with a non-validating parser could miss it, but such a UA would need to have this hardcoded.

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

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters