Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

HTML and XHTML: What You Need to Know

Understand HTML and XHTML with clear explanations, practical examples, and useful tips. This updated guide covers the essential concepts and common mistakes.

Table of Contents

HTML and XHTML is easier to understand when the core ideas are paired with practical examples. The sections below explain the topic clearly, highlight useful steps, and point out details that can prevent common errors.

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 ,, and is 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://tipsmake.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: HTML and XHTML example image 1 

Which must write as below.

 Ngắt dòng: 
 
 Đường nằm ngang: 

 Hình ảnh: HTML and XHTML example image 2 

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

FAQ

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.

What is HTML and XHTML?

XHTML is HTML written in XML language. What is XHTML?

Why is HTML and XHTML important?

A clear understanding of HTML and XHTML helps you make informed decisions, avoid common mistakes, and use the relevant tools or techniques more effectively.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.