Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between .html and .xhtml extension? XHTML is a markup language or it'a different extension also

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

What is the benefit of using the .xhtml extension?

Why we are not using the .xhtml extension, is it just because of IE?

What about .xhtml extension with IE 8?

Is .xhtml supported in other browsers besides IE? If yes, then what benefit we will get when all browsers support the .xhtml extension. Will we stop using .html?

Why do we use the XHTML doctype, but save those files using the .html extension?

like image 959
Jitendra Vyas Avatar asked Dec 28 '09 12:12

Jitendra Vyas


People also ask

What are some of the differences between XHTML and HTML5?

XHTML is a combination of HTML and XML, whereas HTML5 is a version of HTML. XHTML has its own parsing requirements, while HTML does not have any specific requirements and uses its own. In XHTML, all tags, if they are opened, then they should be closed. HTML5 is less strict in this regard.

Which of the following is a difference between HTML and XHTML Mcq?

Explanation: HTML is case insensitive while XHTML is case sensitive. In XHTML, special characters can be escaped using character entites but not in HTML.

How XHTML is different from HTML list the rules followed in XHTML?

XHTML can be thought of as an extension of HTML. HTML is made of elements (with 3 components – pair of element tags, element attributes, and content) while XHTML has only one root element. Secondly, XHTML is a lot stricter when it comes to the file's structure and coding.


2 Answers

If served over HTTP, the file extension has no meaning. The only information that matters it the Content-Type header field where the media type of the resource is specified.

But when served from a local filesystem, the media type is normally identified by the file extension.


Edit    I think the reason for why the extension .html is used even if it’s XHTML is because XHTML is HTML just with XML syntax and everyone is used to .html for HTML documents. (Although most XHTML documents are actually served as HTML as the media type text/html denotes HTML no matter what the document type declaration says.)

But again: extensions are not necessary when requested over HTTP. In HTTP the Content-Type header field tells what media type the resource should be interpreted with. So in theory you could use whatever extension you want or even use no extension at all (useful when content negotiation is used).

like image 69
Gumbo Avatar answered Sep 20 '22 14:09

Gumbo


Use the extension which matches the MIME type:

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

For instance, ePub3 requires .xhtml:

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

References

  • HTML5 and HTML/XHTML
  • Properly Using CSS and JavaScript in XHTML Documents
  • Create rich-layout publications in ePub3 with HTML5, CSS3, and MathML
like image 37
Paul Sweatte Avatar answered Sep 21 '22 14:09

Paul Sweatte