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 xhtml modularization?

660


Which method is used to draw an image on the canvas?

658


Which html tag is used to display the data in the tabular form?

691


Can a single text link point to two different web pages?

713


Is html extensible?

635


How can I learn html?

598


What is web sql database in html 5? Explain

612


What is the difference between innertext and textcontent?

692


What is the sessionstorage object in html5?

617


What is an xhtml element?

658


Explain the advantage of collapsing white space?

675


What are the limits of the text field size?

637


What is w3c recommendation?

620


What is html5 geolocation? How to use it?

654


What is doctype?

674