Well I've been using this spiffed up HTML for quite a while now, and I thought I'd pass it on to you since it is becoming standard.
xHTML is nothing NEW, it is just a title that represents proper coding technique.
I will not be going over document heading/identification of page encryption because that tends to throw people off the guide and make it more of a learning experience rather then the mock up that it truly is.
xHTML only has a few main rules;
1. Always have lowercase tag letters.
br not BR, Br, or bR.
2. Make sure to end every tag even if it has no closing tag.
<br /> not <br>
<img /> not <img>
3. Make sure to properly nestle tagging, do not mix up the ending order.
<p><i>Hi</i></p> not <p><i>Hi</p></i>
To go over why we do this is to break down a browser. Every browser reads the web page in a certain way, for example Mozilla's Firefox parses a set of packets as they come in that contain the HTML source code. As it parses the packets it stores all tags/text into an array and then uses that array to render a webpage. So say you have your HTML source set as;
Firefox will see the '<i>' tag and set itself to wait for a '</i>' closing tag, but in our source we do not have one. So Firefox will react by re-parsing every packet that came after the original declaration of the '<i>' tag and if again there is no closing tag it will either handle an automatic close, or leave it open.HTML Code:<html> <head> </head> <body> <i>Oh-no! </body> </html>
Problem is, the tag '<i>' is not handled as an auto-close tag due to the fact that it only effects text it wraps around so Firefox will leave this tag open causing all the text after the '<i>' to be italicized until a '</i>' closing tag is declared.
Lets review what the main issue stated above is, if you do not close a tag the site will have an error and cause the tag to possible span over all objects declared after the tag and it will cause your site to load slower because the browser will attempt to re-parse data to see if it was a client sided mistake.
And for those of you thinking "This is just because Firefox is awesome and thinks all coders know they are coding properly!" no unfortunately it is not only Firefox that does this, a majority of stream-line browsers handle page loading with this method(IE, Google Chrome, Opera, Safari.)
Results 1 to 9 of 9
Thread: Rules of xHTML.
Threaded View
- 19 Feb. 2010 12:09am #1
- Age
- 30
- Join Date
- Nov. 2009
- Location
- Anaheim, California
- Posts
- 1,065
- Reputation
- 99
- LCash
- 200.00
Rules of xHTML.
Last edited by Chris; 20 Feb. 2010 at 06:45am.