XHTML Syntax

This post explain you how to write the XHTML syntax and how to avoid to write an invalid code. As well as you can learn XHTML write in good manner in terms of structure, case sensitive, well defined.

Double Quotation

Invalid Structure:

<img src=../images/html.jpg width=128 height=128 >

XHTML Valid Structure:

<img src="../images/html.jpg" width="128" height="128" >

Nested Elements

XHTML every tags must be write in nested.

Invalid Structure:

<p><b>Hello, I am writing paragraph line with bold style</p></b>

XHTML Valid Structure:

<p><b>Hello, I am writing paragraph line with bold style</b></p>

Lowercase Elements

XHTML every tags must be write in lowercase.

Invalid Structure:

<LINK TYPE="TEXT/CSS" REL="STYLESHEET" HREF="jnj.css" />
<P>I am writing paragraph text.</P>

XHTML Valid Structure:

<link type="text/css" rel="stylesheet" href="jnj.css" />
<p>I am writing paragraph text.</p>

Elements must be closed

XHTML every tags must be closed correctly.

Invalid Structure:

<LINK TYPE="TEXT/CSS" REL="STYLESHEET" HREF="jnj.css" >
<img src="../images/html.jpg" width="128" height="128" >

XHTML Valid Structure:

<link type="text/css" rel="stylesheet" href="jnj.css" />
<img src="../images/html.jpg" width="128" height="128" />

One Root Element

Every XHTML document only one root element like <html> start root element and end in last of XHTML document.

Valid Structure:

<!DOCTYPE html>
<html>
  <head>
    ...
  </head>
  <body>
    ...
    ...
  </body>
</html>