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

What is html5 and what is it used for?

416


Which video and audio formats are used for embedding on web page?

445


What is image map in html5?

479


State bullet types available in HTML?

495


What is a data list?

438






what are technologies we use in dhtml?

447


List out the tags those are mostly used in html?

448


What is html xhtml and html5?

419


How can we comment in html?

463


What is html6?

476


What is meta tag keywords?

455


How do you play a video using html5?

469


How do you insert a copyright symbol on a browser page?

493


What are the two basic tags in html list?

436


Explain the concept of web storage in html5.

506