" tag; while some elements in HTML can omit the closing tag. XHTML tag names must use lowercase letters; HTML tag names can be uppercase or lowercase.">
Difference: XHTML elements must be nested correctly, and the nesting order of tags must be correct. XHTML elements must be closed, that is, there must be a closing "" tag; while some elements in HTML can omit the closing tag. XHTML tag names must use lowercase letters; HTML tag names can be uppercase or lowercase.
The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.
XHTML: Extensible HyperText Markup Language XHTML (eXtensible HyperText Markup Language) is a standard that redefines HyperText Markup Language HTML (HyperText Markup Language) as an XML application.
HTML Document Specification:
HTTP/1.1 200 OK Content-Type: text/htmlHTML I am a HTML document
XHTML Document Specification:
HTTP/1.1 200 OK Content-Type: application/xhtml+xmlXHTML I am a XHTML document
XHTML Compatibility
Most browsers currently support XHTML, including Firefox, Chrome, Safari, Opera and IE browser (IE 9). (Internet Explorer 8 and older browsers will display a download dialog for an unknown file type when seeing an XHTML document with a properly configured XHTML MIME type). In addition, many popular JavaScript libraries and development tools do not support XHTML.
The difference between HTML and XHTML:
Although XHTML and HTML is almost the same, but it is more important to create the code correctly because XHTML is more strict than HTML in terms of syntax and case sensitivity. XHTML documents are well-formed and parsed using standard XML parsers, unlike HTML which requires a loose HTML-specific parser.
XHTML elements must be nested correctly. Generally, html web pages can be "main content
". This is not strict and is wrong in XHTML; the correct one is in the xhtml standard. This must be required "main content
".
" This tag is feasible in HTML, but for the sake of xhtml standards, it must be closed such as "
” starts, it must be closed with
at the end of the content.Alt attributes need to be added to images. In the past, many times when images were displayed on web pages, the alt attribute could be added or not in the img tag, but now xhtml requires that the alt attribute must be added, otherwise the xhtml verification will prompt an error, even if the alt value is empty. Adding alt can provide a text description for the image, allowing search engines to identify the content of the image, which is a good place to optimize web pages.
Recommended tutorial: "html video tutorial"
The above is the detailed content of What are the differences between html and xhtml?. For more information, please follow other related articles on the PHP Chinese website!