Why is xml:space set to 'preserve' on all elements of XHTML?
I don't want to see extra space in my output.

Answer Posted / guest

The attribute xml:space is about input: that is to say, it
controls if the spaces will be present in the DOM (i.e. in
the internal version of the document inside the browser); it
says nothing about what will appear on your screen. Output
whitespace is controlled by the CSS property 'whitespace'.
Set it to 'pre' and the spaces in the DOM will be preserved
on output; set it to 'normal' and the whitespace will be
collapsed (CSS3 will have more properties to enable greater
control).

This is the reason that all elements are set to
xml:space="preserve" in XHTML2, otherwise the CSS
'whitespace' property would have no effect, and you would
have no control over visible whitespace. The default
stylesheet will set 'whitespace' to 'normal' for all
elements except <pre>, but you will be free to change them.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain five new input types provided by HTML5 for forms?

638


How to handle events with dhtml?

608


List out the tags those are mostly used in html?

591


Why div is used in html?

574


Who developed xhtml?

653


How to add video in background in HTML

1126


What is the meaning of dynamic web page?

649


What is purpose of getCurrentPosition() method of geolocation object of HTML5?

676


Hi Looking for web developer..who has hands on experience with HTML/DHTML, CSS,Javascript,XML. minimum 3.8yrs is mandatory. can reach..srisanh@gmail.com

1877


What does tr mean?

623


How xhtml is better than html?

646


What is an element in coding?

814


What is semantic elements?

589


How do I specify page breaks in html?

694


How we can display

at the center of the webpage?

574