xml:space (HTML attribute)
| Depr. | Version |
|---|---|
| No | XHTML 1.0 |
Syntax
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
- ID:
- #1
- Date:
- Wed, 12 Mar 2008 08:57:11 GMT
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.