WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

HTML and XHTML


XHTML is HTML composed as XML.


What Is XHTML

  • XHTML represents EXtensible HyperText Markup Language
  • It is HTML characterized as XML application
  • It is upheld by all major browsers

Why XHTML

Many pages on the web contain "bad" HTML.

This HTML code works fine in many programs (regardless of whether it doesn't pursue the HTML rules):

<html>
<head>
  <title>This isn't finished HTML</title>

<body>
  <h1>not complete tag HTML
  <p>This is a paragraph
</body>

Today's market comprises of various program advancements. A few programs keep running on PCs, and a few programs keep running on cell phones or other little gadgets. Littler gadgets frequently come up short on the assets or capacity to decipher "bad" markup.

XML is a markup language where archives must be increased accurately (be "well-formed").

If you need to consider XML, if you don't mind read our XML tutorial.

By consolidating the qualities of HTML and XML, XHTML was developed.

XHTML is HTML updated as XML.


The Most Important Differences from HTML:

Document Structure

  • XHTML DOCTYPE is mandatory
  • The xmlns characteristic in <html> is mandatory
  • <html>, <head>, <title>, and <body> are mandatory

XHTML Elements

  • XHTML components must be appropriately nested
  • XHTML components should dependably be closed
  • XHTML components must be in lowercase
  • XHTML archives must have one root element

XHTML Attributes

  • Attribute names must be in lower case
  • Attribute values must be quoted
  • Attribute minimization is forbidden

<!DOCTYPE ....> Is Mandatory

An XHTML record must have a XHTML DOCTYPE declaration.

A complete rundown of all the XHTML Doctypes is found in our HTML Tags Reference.

The <html>, <head>, <title>, and <body> components should likewise be available, and the xmlns characteristic in <html> must determine the xml namespace for the document.

This precedent demonstrates a XHTML record with at least required tags:

<!DOCTYPE html Open "-/W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <title>Title of document</title>
</head>

<body>
  some content
</body>

</html>

XHTML Elements Must Be Properly Nested

In HTML, a few components can be inappropriately settled inside one another, as this:

<b><i>This content is strong and italic</b></i>

In XHTML, all components must be appropriately settled inside one another, as this:

<b><i>This content is intense and italic</i></b>

XHTML Elements Must Always Be Closed

This is wrong:

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

This is correct:

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

Empty Elements Must Also Be Closed

This is wrong:

A break: <br>
An even guideline: <hr>
A picture: <img src="happy.gif" alt="Happy face">

This is correct:

A break: <br/>
A level principle: <hr/>
A picture: <img src="happy.gif" alt="Happy face"/>

XHTML Elements Must Be In Lower Case

This is wrong:

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

This is correct:

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

XHTML Attribute Names Must Be In Lower Case

This is wrong:

<table WIDTH="100%">

This is correct:

<table width="100%">

Attribute Values Must Be Quoted

This is wrong:

<table width=100%>

This is correct:

<table width="100%">

Attribute Minimization Is Forbidden

Wrong:

<input type="checkbox" name="vehicle" value="car" checked/>

Correct:

<input type="checkbox" name="vehicle" value="car" checked="checked"/>

Wrong:

<input type="text" name="lastname" incapacitated/>

Correct:

<input type="text" name="lastname" disabled="disabled"/>

How to Convert from HTML to XHTML

  1. Add a XHTML <!DOCTYPE> to the principal line of each page
  2. Add a xmlns credit to the html component of each page
  3. Change all component names to lowercase
  4. Close all void elements
  5. Change all credit names to lowercase
  6. Quote all characteristic values

Validate XHTML With The W3C Validator

Put your web address in the case below: