HTML and XHTML

XHTML is HTML written in XML language.

XHTML is HTML written in XML language.

What is XHTML ?

  1. XHTML stands for Extensible HyperText Markup Language (Extended Hypertext Markup Language)
  2. XHTML is similar to HTML
  3. XHTML has stricter rules than HTML
  4. XHTML is HTML defined as an XML application
  5. 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

  1. XHTML DOCTYPE is required
  2. The xmlns attribute in the tag is required.
  3. Tags ,, and is required.

Elements in XHTML

  1. Elements in XHTML must be properly nested.
  2. Elements in XHTML must always be closed.
  3. Elements in XHTML must be lowercase.
  4. Elements in XHTML must have a root element.

Properties in XHTML

  1. Attribute names must be in lowercase.
  2. Attribute value must be in quotation marks.
  3. 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: Happy

Which must write as below.

 Ngắt dòng: 

Đường nằm ngang:


Hình ảnh: Happy

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

  1. Add XHTML to the first line of each page
  2. Add xmlns attribute to the html element of each page
  3. Change all element names to lower case
  4. Close all empty elements
  5. Change all attribute names to lower case
  6. Put a quote on all attribute values

Previous article: Uniform Resource Locators in HTML

The following article: Form in HTML

Update 25 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile