HTML - XHTMLLOGIN

HTML - XHTML

HTML - XHTML

XHTML is HTML written in XML format.

What is XHTML?

XHTML refers to Extensible Hypertext Markup Language

XHTML is almost the same as HTML 4.01

XHTML is more strict A purer version of HTML

XHTML is HTML defined in the form of XML applications

XHTML is a W3C recommendation standard released in January 2001

XHTML is available in all major browsers Support

Why use XHTML?

Many pages on the Internet contain "bad" HTML.

If viewed in a browser, the following HTML code runs perfectly fine (even though it does not follow HTML rules):

<html><head><meta charset= "utf-8"><title>This is an irregular HTML</title><body><h1>Irregular HTML<p>This is a paragraph</body>

XML is a markup language that must be correctly marked up and well-formed.

If you want to learn XML, read our XML tutorial.

There are a number of different browser technologies in today’s tech world. Some of them run on computers, while others may run on mobile phones or other small devices. Small devices often lack the resources and capabilities to interpret "bad" markup languages.

So - XHTML was developed by combining the best of XML and HTML. XHTML is HTML redesigned as XML.

The most important difference compared to HTML:

Document structure

XHTML DOCTYPE is mandatory

XML namespace attribute in<html> are mandatory

<html>, <head>, <title> and <body> are also mandatory

Element syntax

XHTML elements are required Correct nesting

XHTML elements must always be closed

XHTML elements must be lowercase

XHTML documents must have a root element

Attribute syntax

XHTML attributes must be in lower case

XHTML attribute values ​​must be surrounded by quotes

XHTML attribute minimization is also prohibited

<!DOCTYPE ....> is mandatory Sexual

XHTML documents must carry an XHTML document type declaration (XHTML DOCTYPE declaration).

You can find the complete XHTML document type in the Tag Reference Manual of the Rookie Tutorial. The

<html>, <head>, <title>, and <body> elements must also be present, and the xml namespace must be specified for the document using the xmlns attribute in <html>.

XHTML elements must be nested reasonably

In HTML, some elements do not need to be nested within each other, like this:

<b><i>Bold and italic text</b></i>

In XHTML, all elements must be properly nested within each other, like this:

<b><i>Bold and italic text</i></b>

XHTML elements must have a closing tag

Incorrect example:

<p>This is a paragraph<p>This is another paragraph

Correct example:

<p>This is A paragraph</p><p>This is another paragraph</p>

Empty elements must contain closing tags

Error example:

Branch:<br>Horizontal line: <hr>Image: <img src="happy.gif" alt="Happy face">

Correct example:

Branch:<br />Horizontal line: <hr />Image: <img src="happy.gif" alt="Happy face" />

XHTML element required is lowercase

Incorrect example:

<BODY><P>This is a paragraph</P></BODY>

Correct example :

<body><p>This is a paragraph</p></body>

Attribute names must be lowercase

Incorrect example:

<table WIDTH="100%">

Correct example:

<table width="100%">

Attribute values ​​must have quotation marks

Incorrect example:

<table width=100%>

Correct example:

<table width="100%">

Attribute abbreviation not allowed

Error example:

<input checked><input readonly> <input disabled><option selected>

Correct example:

<input checked="checked"><input readonly="readonly"><input disabled= "disabled"><option selected="selected">


How to convert HTML to XHTML

Add a XHTML <!DOCTYPE> Go to your web page

Add the xmlns attribute to the html element of each page.

Change all elements to lowercase

Close all empty elements

Change all attribute names to lowercase

Add quotation marks to all attribute values


Next Section
<html> <meta charset="utf-8"> <body> hello xhtml </body> </html>
submitReset Code
ChapterCourseware