开发者

Can someone explain what the xml:space attribute is used for in XHTML5?

开发者 https://www.devze.com 2023-01-26 01:29 出处:网络
I was wondering what does the xml:space attribute do and what are it\'s values in XHTML5. an开发者_开发百科d does the xml:space attribute have any restrictions?There is no such a thing as XHTML5. If b

I was wondering what does the xml:space attribute do and what are it's values in XHTML5. an开发者_开发百科d does the xml:space attribute have any restrictions?


There is no such a thing as XHTML5. If by "XHTML5", you mean HTML5, than:

The XML specification also allows the use of the xml:space attribute in the XML namespace on any element in an XML document. This attribute has no effect on HTML elements, as the default behavior in HTML is to preserve whitespace.

From http://www.w3.org/TR/html5/elements.html

Now, for XML documents in general, xml:space specifies the way the spaces are handled. Two possible values are default and preserve. Default will trim all spaces to a single space (except in CDATA). Preserve will keep the number of consecutive spaces as is.

In HTML, spaces are always preserved. It allows for example to use <pre/> tag, or white-space property in CSS.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号