XHTML Why Require

Why XHTML is require?
XHTML is a combination of HTML and XML. so HTML code is work good but, element tag is not follow any HTML rules.

  • Following one example, its code run on browser is properly but tag is not follow any certain condition or rules.

  • Here use in XHTML than the all container tag is opening as well as closing rules are follow and code write in well-formed.

<!DOCTYPE html>
<html>
<head>
  <title>Invalid HTML Example</title>
</head>
<body>
  <p>This is Paragraph Tag
  <img src=../images/html.jpg >
  <h3>THis is a Heading Size of 3
</body>
</html>

  • XHTML is markup language so everything is write on marked up correctly as well as well-formed.

  • Above HTML bad code example is start to write on XHTML well-formed like following.

<!DOCTYPE html>
<html>
<head>
  <title>Valid HTML Example</title>
</head>
<body>
  <p>This is Paragraph Tag</p>
  <img src="../images/html.jpg" alt="html image"/>
  <h3>THis is a Heading Size of 3</h3>
</body>
</html>