Editor:Steven Pemberton,W3C/CWI
Release Date: July 21, 2004
This document is no longer maintained.
Other related FAQs:
- W3C Web Internationalization FAQ
- Accessibility of web content
- Frequently Asked Questions about XForms 1.0
- A list of all available W3C FAQs
To comment on this document or submit suggested questions, send an email towww-html-editor@w3.org, including the word FAQ in the subject line.
table of contents
- Why is XHTML necessary? HTML not good enough?
- What are the advantages of using XHTML over HTML?
- Can I just override the XML declaration over existing HTML documents? Can I mix HTML 4.01 and XHTML documents?
- What's the easiest way to convert my HTML documents to XHTML?
- Why are browsers so picky about XML? They were more accepting of HTML.
- Why should I care if my document is in the correct HTML? It shows everything fine in my browser.
- Where can I check that my document is using the correct markup?
- Why does everyone say "user agent" instead of "browser"?
- Why do I need to use these namespaces in XHTML?
- Why is it allowed to send XHTML 1.0 documents as Text/HTML?
- Which browsers support the application/xhtml+xml media type?
- Does Microsoft Internet Explorer support the application/xhtml+xml media type?
- CSS has many special rules that only apply to HTML. Does this also apply to XHTML?
- Document.write works in XHTML?
- Why is it not allowed to send XHTML 1.1 documents as text/HTML?
- Why was the target attribute removed from XHTML 1.1?
- What is XHTML modularization for?
- Why is XHTML2 necessary? Is XHTML 1 not good enough?
- Will <img> be replaced by <object> in XHTML2?
- Why doesn't XHTML2 use XLink?
- Why is XHTML2 not backward compatible?
- Why is xml:space set to 'preserve' for all XHTML elements? I don't want to see extra space in my output.
Why is XHTML necessary? HTML not good enough?
HTML is probably the most successful document markup language in the world. But when XML was introduced, a two-day workshop was organized to discuss whether a new version of HTML was needed in XML. The opinion at the workshop was a resounding 'yes': with HTML based on XML, other XML languages could contain parts of XHTML and XHTML documents could contain parts of other markup languages. We could also use redesign to clean up some of the messier parts of the HTML and add some needed new features like better forms.
What are the advantages of using XHTML over HTML?
If your document is just pure XHTML 1.0 (with no other markup languages), you still won't notice much of a difference. However, as more and more XML tools become available, such as B.XSLT for transforming documents, you will see the benefits of using XHTML. XForms, for example, allow you to edit XHTML documents (or any other type of XML document) in a simple and controllable way. Semantic Web applications will be able to use XHTML documents.
If your document is higher than XHTML 1.0, for example if it contains MathML, SMIL or SVG, the advantages are obvious: you can't do something like this with HTML.
Can I just put the XML declaration in existing HTML documents? Can I mix HTML 4.01 and XHTML documents?
No. The HTML is not in XML format. You must make the necessary changes to convert the document into proper XML before you can accept it as XML.
What's the easiest way to convert my HTML documents to XHTML?
clean htmlprovides the ability to convert any HTML document into an XHTML document.amayais a browser/editor that saves HTML documents as XHTML.
Why are browsers so picky about XML? They accepted more with HTML.
This is on purpose. HTML browsers take any input, correct or incorrect, and try to do something useful with it. This bug fix makes browsers very difficult to write, especially when all browsers are expected to do the same. It also caused the corruption of many HTML documents as the author is unaware of the errors as they appear correctly in the browser. This makes writing new web user agents incredibly difficult, as documents that claim to be HTML are often pretty bad.
Why should I care if my document is in the correct HTML? It displays correctly in my browser.
All browsers know how to handle the correct HTML. However, when it's wrong, the browser needs to fix the document, and since not all browsers fix documents the same way, this has differences, so your document may look and function differently in different browsers. Since there are hundreds of different browsers and the number is growing all the time (not only on PCs, but also on PDAs, cell phones, TVs, printers and even refrigerators), it is impossible to test your document in all browsers. If you use bad HTML and your document doesn't work in a particular browser, that's your fault; If you are using correct HTML and it doesn't work, it's a browser bug.
Where can I check that my document is using the correct markup?
The W3C offers a service inhttp://validator.w3.org/. HeamayaThe browser/editor also ensures that your markup is correct.
Why does everyone say "user agent" instead of "browser"?
While browsers are the primary users of HTML and XHTML, there are other programs and systems that read these documents. For example, search engines read documents, but browsers do not. By using the term "user agent" we are trying to remind people of the difference.
For example, if you do a Google search often, you'll see something like "This site uses frames, but your browser doesn't support it" in some search results, which will certainly discourage some people from clicking that link. The author of the site in question didn't realize that there are more than just browsers and that they should put better text in theirs.<no frames>
Section so they don't look so stupid when people search your site.
Why do I need to use these namespaces in XHTML?
In the early days of HTML, various groups and companies added new elements and attributes to HTML at will. This threatened to create a mess of different non-interoperable HTML versions. XML (the X stands for Extensible) allows anyone to use elements and elements from different languages, but for a browser or other user agent to know which element belongs to which language, it needs to tell you. Namespace declarations do just that.
Why is it allowed to send XHTML 1.0 documents as Text/HTML?
XHTML is an XML format; that is, strictly speaking, it must be sent with an XML-related media type (application/xhtml+xml
,application/xml
, otexto/xml
). However, XHTML 1.0 was carefully designed to work with older HTML user agents as well. By following a few simple guidelines, you can make many XHTML 1.0 documents work in older browsers. However, older browsers only understand the text/html media type, so you must use that media type when submitting XHTML 1.0 documents. But be careful when sending XHTML documents to browsers liketext/html
means these browsers will see the documents as HTML documents, not XHTML documents.
Which browsers support the application/xhtml+xml media type?
The browsers we know are all based on Mozilla, such as Mozilla, Netscape 5 and above, Galeon and Firefox, as well as Opera, Amaya, Camino, Chimera, DocZilla, iCab, Safari and all browsers on mobile phones that support WAP2. In fact, all modern browsers. Most accept XHTML documents asapplication/xml
as well as. see theXHTMLMedia-Typ-Testfor details.
Does Microsoft Internet Explorer support the application/xhtml+xml media type?
No. However, there is a trick you can use to serve XHTML1.0 documents like Internet Explorerapplication/xml
.
At the top of your document, add the bold line here:
<?version xml="1.0" codification="iso-8859-1"?><?xml-stylesheet type="text/xsl" href="copy.xsl"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http ://www.w3.org/1999/xhtml"><head>
Wocopy.xsl
is a file that contains:
<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform"> <template match="/"> <copy of select="."/> </ template> < /folha de estilo>
Note that this file must be in the same location as the document it refers to.
Even though you provide the document as XML and it is parsed as XML, the browser assumes it was receivedtext/html
and therefore your XHTML1.0 document must follow many of the guidelines for legacy browser delivery.
Your XHTML document will still work in browsers that accept XHTML1.0 asapplication/xml
.
CSS has many special rules that only apply to HTML. Does this also apply to XHTML?
No. CSS rules that apply only to HTML only apply to documents delivered astext/html
.
Document.write works in XHTML?
No. Due to the way the XML is defined, it is not possible to do tricks like this where the markup is scripted while the parser is still parsing the markup.
You can still get the same effects, but you have to do it using the DOM to add and remove elements.
Why is it not allowed to send XHTML 1.1 documents as text/HTML?
XHTML 1.1 is pure XML and is for XML only. Unable to deliver reliably to older browsers. Therefore, XHTML 1.1 documents must be submitted with an XML-related media type, for example, for example, application/xhtml+xml.
Why was the target attribute removed from XHTML 1.1?
Was not. XHTML 1.0 comes in three versions: Strict, Transitional, and Frameset. All three have deliberately stayed as close to HTML 4.01 as XML allows. XHTML 1.1 is an updated version of XHTML 1.0strictly, and no version of strict HTML included thismeta
Attribute. The other two versions, Transition and Frameset, were not updated because there was nothing to update. If you want to use themeta
use of XHTML 1.0 Transitional attributes.
What is XHTML modularization for?
XHTML Modularization is not intended for ordinary XHTML users, but for designers of XHTML-based languages. It was observed that companies and corporations tended to design their own versions of HTML and XHTML, which were often not interoperable at fundamental levels. XHTML modularization breaks XHTML into a series of modules that can be individually selected when defining a new language; This ensures that all XHTML-based languages that use tables use the same table definition and not a different version. Modularization also makes it clear where new elements can be added and where not.
Why is XHTML2 necessary? Is XHTML 1 not good enough?
HTML and XHTML served us well, but there are many things that could be improved. Areas that received special attention include better ways of structuring, removal of duplicate resources in XML, ease of use, accessibility, internationalization, device independence, better forms, and reducing the need for scripts.
Will <img> be replaced by <object> in XHTML2?
NO.<Image>
is replaced in XHTML2, but with something different (although you can use<Object>
Yes you want).
the project of<Image>
has many problems in HTML:
- It has no fallback functions, so if you are using, for example, a PNG type image and the browser does not support this type, the only alternative is to use the
alternative
Text. This fact has hindered the adoption of PNG images, which are better than GIF and JPG in many ways, as people continue to use the lowest common denominator format to ensure that images can be seen by all. - He
alternative
The text cannot be tagged so if you use it you will just get the plain text. - is possible a
langabst
Link to an image description to help people who can't see it, but it's rarely implemented.
What XHTML2 says is that all images match content; it does this by letting you define aThose ones
assign to an element at all. This means: if the image is available and the browser can handle it, use it; otherwise, use the element's content. For example:
<p src="map.png">Exit the station, turn left, go up <strong>High Street</strong> and turn right</p>
This has the advantage that your document can still be used if the image is not available for some reason (eg network failure) or if the browser is unable to display that type of image. If you want to provide more than one type of image, do the following:
<p src="map.png"><span src="map.gif">Sair da parada...</span></p>
although it's better to use content negotiation if your server supports it (and most do):
<p src="map">Exit stop...</p>
which would negotiate with the browser what type of image to accept and give the browser its preferred type. If no image is available, the element's content will be used. This has the added benefit that you can later add other types of images to your server and you don't have to change the page to keep it working.
Why doesn't XHTML2 use XLink?
XLink and XHTML had different linking requirements that turned out to be incompatible.
Why is XHTML2 not backward compatible?
It is, but in a different way than previous versions of HTML that were backwards compatible.
Since previous versions of HTML were special languages, a certain level of backwards compatibility had to be ensured so that new documents could also be used in older browsers. This is, for example, the reason for<Meta>
-The element has its content in an attribute and not in the element's content as it would be displayed in older browsers.
However, thanks to XML and stylesheets, this strict backward compatibility of elements is no longer necessary as an XML-based browser, which at the time of writing means over 95% of browsers in use, it can handle with new markup languages. no need for updates. Much of XHTML 2already works in existing browsers, browsers that are not pre-programmed to accept XHTML2. A lot works, but not everything: when forms and tables were added to HTML, people had to wait for new browser versions; likewise, some parts of XHTML 2, such as XForms and XML Events, still require user agents that understand this functionality.
Why is xml:space set to 'preserve' for all XHTML elements? I don't want to see extra space in my output.
the attributexml:space
is aboutProhibited: That is, it controls whether there are spaces in the DOM (that is, in the internal version of the document in the browser); it says nothing about what will appear on the screen. Output whitespace is controlled by the CSS property 'spaces
'. bridge 'Before
' and spaces in the DOM are preserved on output; put it'normal
' and whitespace will be reduced (CSS3 will have more properties to allow for better control).
For this reason, all elements are set toxml:space="preserve"
in XHTML2, otherwise the CSS'spaces
' would have no effect and no control over the visible spaces. The default stylesheet will be set'spaces
' A 'normal
' for all elements except<before>
, but you are free to change them.
Copyright ©©2004W3C®(SWINDLER,ERCIM,keio), All rights reserved. w3cResponsibility,Commercial brand,use of documentsYsoftware licensesrules apply. Your interactions with this site are governed by ourpublicYMemberPrivacy Statements.