Hosting Solutions  
 
   |  Tutorials Home  |  Privacy | 









Secured by RapidSSL



2 XHTML Intro XHTML Tags:

The biggest change to the HTML you have been used to using, is that tags must now always be properly formed. With the old HTML specification you could be a bit sloppy in your coding, with missing tags and incorrect formation without a lot of problems, but XHTML changes all of that. Proper tag format is very important.

Lower Case Tags Only:

In XHTML, all tags must always be lower case. For instance, this:

    <IMG>
    <Img>

... just won't do. The img tag must now be used as follows: <img>

Note- If you must use a WYSIWYG editor, you can still begin to migrate your documents to XHTML by setting it to show all code in lower case.

Nesting

Next, all of your tags must be properly nested. If you have several different tags that apply to the same thing in your document, then you must make sure that you open and close them in the correct order. For example, this is correct:

    <em><strong><font face="arial">Text</font></strong></em>

.... while this is definitely not correct:

    <strong><em><font face="arial">Text</font></strong></em>

And one more very common mistake to keep away from is this:

    <font color="#FFAA00">Text</font>

Did you spot the goof? Yup, it's the font color attribute, which is erroneously in UPPERCASE. Many tools used to pick colors still use the long outdated all caps format. This will generate an XHTML error. You may also have noticed the use of the <strong></strong> being used instead of the more familiar <b> for bold print, and the <em></em> tags in place of the old <i> tags for italics; the old style has been deprecated-- be sure to use the new ones.

Closing Tags

All tags used in XHTML must be closed. The following tags, which used to be 'standalone"-- <hr>, <br /> and <img>, must now be closed; this may take a little getting used to, but it is nevertheless required. Here are the proper forms for these tags now:

    < /br> < /img>
    < /hr>

Please notice the space between the first bracket '<' and the forward slash '/' .... that space must be there, and is a part of the tag format-- not a mistake. Remember the Space!

So why does the newline <br /> tag have to be closed? You'll have the ask the W3C gurus that question, because it makes no logical sense to me, either, but it does have to be done, or you get errors. The rumor mill has it that Netscape could not handle XHTML otherwise... but who really uses Netscape anymore? (Just Kidding, don't get sore!). Here are some examples of the above, for clarification:

    A sample line of text<br /><br />
    <img src="/images/b3.gif" width="12" height="11" border="0" alt="Web Site Hosting" />
    <hr style="color: red;"><hr />
In case you are wondering how the <img> tag works if it has all the normal attributes included, here is an example:
    <img src="myimage.gif" alt="My Image" width="400" height="300" />


That just about covers the XHTML tags. Next, we'll get into the last of the new stuff you need to know, Xhtml Attributes.








Updated on Thursday, 01~26~2012

Copyright © 1998 - 2012
Bill Payne & Sitebilder© Network