HTML VS XHTML


Summary

In web designing, it’s crucial to understand the differences in languages. For example, HTML and XHTML have many things in common, but there are rules that change. In HTML, tags can be nested incorrectly, some tags don’t have to be closed, tags can be written in CAPITAL letters, and values don’t have to be “quoted.” None of these are allowed in XHTML. These rules are the basic differences between coding in HTML and XHTML.


Examples of tag changes

1. HTML: <P></P>, XHTML: <p></p>
2. HTML: <br>, XHTML: <br />
3. HTML: <img src=“image.jpg”>, XHTML: <img src=“image.jpg” alt=“image” />
4. HTML: <table border=0 >, XHTML: <table border=“0”>
5. HTML: <b><u>text</b></u>, XHTML: <b><u>text</u></b>
6. HTML: <hr>, XHTML: <hr />
7. HTML: <input checked>, XHTML: <input checked=“checked”>
8. HTML: <name=“text”>, XHTML: <id=“text”>
9. HTML: <font face=“Arial”>, XHTML:<font-family=“Arial”>
10.HTML:<script language=“javascript”>, XHTML:<script type=“text/javascript”>

Examples of coding changes in XHTML

1. <!DOCTYPE…> must be enter before the <html> tag
2. <html xmlns="http://www.w3.org/1999/xhtml"> instead of just <html>
3. In XHTML Strict, depreciated tags can’t be use unless in CSS; however, you can still control some style elements such as height and width within tags such as: <table border=“0”, height=“1000” width=“1000”>
4. <ol><li>text<ul><li>text</li></ul></li></ol> instead of forgetting the last </li> and just closing with </ol>, which is improper nesting
5. In XHTML Strict, all empty tags must be written within other tags such as: <p><br /></p>


Resources

1. __http://www.w3schools.com/__
2. __http://validator.w3.org/__
3. __http://jessey.net/simon/xhtml_tutorial/__