HTML and XHTML
XHTML is HTML written in XML language.
XHTML is HTML written in XML language.
What is XHTML ?
- XHTML stands for Extensible HyperText Markup Language (Extended Hypertext Markup Language)
- XHTML is similar to HTML
- XHTML has stricter rules than HTML
- XHTML is HTML defined as an XML application
- XHTML is supported by most popular browsers
Why use XHTML?
Many sites on the Internet contain 'very bad' HTML, although they do not follow HTML rules but still work on many browsers. The following is an example of a non-compliant HTML paragraph, but still works.
HTML không đúng quy định
'Bad' HTML
Network administrator.
Today there are many browser technologies, which can run on computers, phones or other small devices. These small devices often lack the resources or the power to translate 'bad' markups.
XHTML is a markup language in which documents must be properly marked, developed by combining the power of both HTML and XML.
Important differences between HTML and XHTML
Text structure
- XHTML DOCTYPE is required
- The xmlns attribute in the tag
is required.
- Tags
,,
andis required.
Elements in XHTML
- Elements in XHTML must be properly nested.
- Elements in XHTML must always be closed.
- Elements in XHTML must be lowercase.
- Elements in XHTML must have a root element.
Properties in XHTML
- Attribute names must be in lowercase.
- Attribute value must be in quotation marks.
- It is forbidden to simplify attributes.
is required
XHTML text must contain XHTML DOCTYPE declaration.
Must have elements ,,
and , xmlns attribute in the tag
must specify xml space for text. The example below shows XHTML text with minimum required tags.
"https://quantrimang.com/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Tiêu đề văn bản
nội dung
XHTML elements must be properly nested
In HTML, some elements can be nested within the same way as the example below.
Văn bản in đậm và in nghiêng
But in XHTML, all elements must be properly nested, as in the example below.
Văn bản in đậm và in nghiêng
XHTML elements must always be closed
Writing as below is wrong
Paragraph 1
Paragraph 2
It must be this:
Paragraph 1
Paragraph 2
Empty elements must also be closed
As the example below is invalid.
Ngắt dòng:
Đường nằm ngang:
Hình ảnh:
Which must write as below.
Ngắt dòng:
Đường nằm ngang:
Hình ảnh:
Elements in XHTML must be written in lowercase
Writing as below is wrong.
Paragraph
Which must write lowercase as below.
Paragraph
Attribute names in XHTML must be written in lowercase
Do not write
but must write
Attribute value must be in quotation marks
Do not write but must write
Do not simplify attributes
False
It's correct
False
It's correct
How to convert from HTML to XHTML
- Add XHTML to the first line of each page
- Add xmlns attribute to the html element of each page
- Change all element names to lower case
- Close all empty elements
- Change all attribute names to lower case
- Put a quote on all attribute values
Previous article: Uniform Resource Locators in HTML
The following article: Form in HTML
You should read it
- eQuiz - Multiple choice test on XHTML
- Website construction: HTML and XHTML tricks
- Introduction to HTML
- Top 10 HTML tags that each blog and website owner should know
- 5 steps to learn a dynamic HTML web component profile
- Basic examples of HTML
- Paths in HTML
- Configure Windows XP SP2 network protection technologies on a computer (Part III)
- HTML form
- PHP & XML
- Elements in HTML
- eQuiz - Multiple choice test on HTML knowledge
Maybe you are interested
The Hubble Telescope discovered a pair of small dwarf galaxies containing many interesting features Hubble telescope discovers more than 1,000 new asteroids The Hubble Telescope finds a galaxy glowing strangely from behind a dark nebula Lonely star glitters in the background of an amorphous galaxy in the eyes of the Hubble telescope Fastest star in the Milky Way, speed 8,226,967 km/h Astrophysics professor teaches how to jump into a black hole so it's 'safe' and possible events