Home >Web Front-end >HTML Tutorial >How to differentiate between HTML and XHTML? What is the difference between HTML and XHTML?
This chapter will introduce to you how to distinguish between HTML and XHTML? What is the difference between HTML and XHTML? It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
What is XHTML?
Label.
The differences between XHTML and HTML are mainly divided into two categories:
Functional differences: The main reason is that XHTML can be compatible with various Large browsers, mobile phones and PDAs, and the browser can quickly and correctly compile web pages.
Differences in writing habits: Because the syntax of XHTML is relatively strict, you must write code according to the rules of XHTML when writing
The main differences between XHTML and HTML are as follows:
1. # Error:
Correct:
2. Tags appear in pairs
When a tag appears, there must be a corresponding end tag, both are indispensable.
Wrong:
Hello everyone
My name is WYH
Correct:
Hello everyone
My name is WYH p>
3. XHTML requires correct nesting of
tags from outside to inside, wrapped layer by layer. Follow the "first in, last out" principle.
Error:
This is the wrong nesting relationship
Correct:
This Is the correct nesting relationship
4. XHTML attribute values must be enclosed in double quotes
In XHTML 1.0, it is stipulated that even single quotes cannot be used. So you have to use double quotes.
Incorrect:
Correct:
5. It is not allowed to use target="_blank"
Starting from XHTML1.1, the target attribute is completely prohibited. If you want to open a new window, you can only use rel="external".
Error: Baidu
Correct: Baidu
6. Empty elements need to be preceded by spaces and slashes before ">"
For example:
The above is the detailed content of How to differentiate between HTML and XHTML? What is the difference between HTML and XHTML?. For more information, please follow other related articles on the PHP Chinese website!