Xhtml and Html Difference
The most important difference between Xhtml and Xhtml :
HyperText Markup Language (HTML), is an application of SGML (Standard Generalized Markup Language), and allows to omit certain tags.
The Extensible HyperText Markup Language (XHTML), is an application of XML (Extensible Markup Language). It doesn’t permit the omission of any tags. Xhtml provides a shorthand notation for empty elements: For eg: we could use <br/> instead of <br></br>.
The Most Important Differences:
- XHTML elements must be properly nested
- XHTML elements must always be closed
- XHTML elements must be in lowercase
- XHTML documents must have one root element
XHTML Elements Must Be Properly Nested
Following example for improper nesting :
<b><i>This text is bold and italic</b></i>
Following example for proper nesting :
<b><i>This text is bold and italic</i></b>
XHTML Elements Must Always Be Closed
Wrong Method:
<p>This is a paragraph
<p>This is another paragraph
Correct Method
<p>This is a paragraph</p>
<p>This is another paragraph</p>
XHTML Elements Must Always Be Closed
Wrong Method:
A break: <br>
A horizontal rule: <hr>
Correct Method
A break: <br/>
A horizontal rule: <hr/>
XHTML Documents Must Have One Root Element
<html>
<head> ... </head>
<body> ... </body>
</html>
|