Difference between HTML vs XHTML
They are some changes in XHTML as compared to the HTML.The most important differences are
Document section:
1) All documents should have DOCTYPE
2) The xmlns attributes in< html> is compulsory.
3)<html>,<head>,<title>,<body> these tags are compulsory.
XHTML Elements:
1) XHTML Elements must be Properly nested.
2) XHTML Elements must be Always in closed and lowercase.
3)XHTML Document must have One root element.
XHTML Attributes:
1) Attributes names must be in Lower case.
2) Attributes values must be in Quoted.
3) Attributes minimization is Forbidden.
Explanation of XHTML Elements and Attributes with example:
1) XHTML Elements must be Properly Nested:
In HTML, some elements can be improperly nested with each other like this example
Ex:<b><i>This text is bold and italic </b></i>
In XHTML. all elements must be properly nested within each other like this example
Ex: <b><i>This text is bold and italic </i></b>
Note: See the difference between two
2) XHTML Elements must always be Closed:
Wrong Method:
<p>This is simple paragraph
<p>This is another simple paragraph
This code follows Bad HTML
Correct Method:
<p> This is simple paragraph </p>
<p> This is another simple paragraph </p>
IN HTML:
- Break : <br>
- Horizontal rule: <hr>
- Image : <img src="charan.gif" alt="charan photo">
IN XHTML:
- Break: <br />
- Horizontal rule : <hr />
- Image : <img src="charan.gif" alt="charan photo" />
XHTML attributes and Elements must be in Lower cases.
correct method:
Examples:
1)
<body>
<p> this is paragraph </p>
</body>
2) <table width="100%" />
Wrong method:
Examples:
1)
<BODY>
<p> this is paragraph </P>
</BODY>
2) <table width=100% />
Attributes Minimization is Forbidden :
Correct method:
<input type="checkbox" name="vehicle" value="car" checked="Checked" />
Wrong method:
<input type="checkbox" name = "vehicle " value ="car" checked />
correct method:
Examples:
1)
<body>
<p> this is paragraph </p>
</body>
2) <table width="100%" />
Wrong method:
Examples:
1)
<BODY>
<p> this is paragraph </P>
</BODY>
2) <table width=100% />
Attributes Minimization is Forbidden :
Correct method:
<input type="checkbox" name="vehicle" value="car" checked="Checked" />
Wrong method:
<input type="checkbox" name = "vehicle " value ="car" checked />
NOTE: Remember wrong method is mostly applicable in HTML but not in XHTML
Difference between HTML vs XHTML || XHTML part 3
Reviewed by TECH UPDATE
on
April 19, 2018
Rating:
No comments: