What is the difference between the .html and .xhtml extension? XHTML is a markup language, or is this another extension also

What is the difference between .html and .xhtml file .xhtml ?

What is the advantage of using the .xhtml extension?

Why don't we use the .xhtml extension, is it just because of IE?

What about the .xhtml extension with IE 8?

Is .xhtml in browsers other than IE? If so, what advantage will we get when all browsers support the .xhtml extension. Will we stop using .html ?

Why do we use doctype XHTML but save these files with the .html extension?

+7
html mime-types xhtml doctype file-extension
source share
6 answers

If HTTP is used, the file extension does not make sense. The only information that matters to it is the Content-Type header field , where is the type of resource media.

But when servicing from the local file system, the type of medium is usually determined by the file extension.


Edit I think the reason is why the .html extension is used, even if its XHTML is because XHTML is HTML only with XML syntax, and all are used for .html HTML documents. (Although most XHTML documents are actually used as HTML, as text like text / html means HTML no matter what the document type declaration says.)

But again: when requesting via HTTP, extensions are not needed. The HTTP Content-Type header field indicates which media type the resource should interpret. Therefore, theoretically, you can use any extension you want, or even not use the extension at all (useful when content negotiation is used).

+13
source share

Use the extension corresponding to the MIME type:

  • .xhtml for application/xhtml+xml documents
  • .html for text/html documents

For example, ePub3 requires .xhtml :

It is highly recommended that you use the .xhtml extension for all EPUB content documents. Browsers will not interpret HTML content as application / xhtml + xml without this extension.

References

+3
source share

IE (including IE8) is the only (significant) browser that does not support XHTML, which is served as application/xhtml+xml (corresponds to the xht or xhtml extensions).

Will everyone move to XHTML when IE supports it? Probably no. XML is not easy to get right, especially if you need to include data provided by the user, such as blog comments. (Although this can be resolved with (X) HTML5 <iframe sandbox> before IE starts playing.) However, I don't have a crystal ball, so we just need to wait and see what happens.

+2
source share

No one cares about what file is named, only what the MIME type was ported to.

+1
source share

Browsers do not rely (simply) on the page extension, but in the MIME content type. Thus, you can, for example, create a PHP page that serves as a JPG image.

0
source share

I think the xhtml extension is only used for XHTML, but it is rarely used because the HTML type you are using is defined in the DOCTYPE element.

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
-one
source share

All Articles