Electric Type

Multimedia

About Us

News

Help

XHTML Overview

Page 3 — Tags in XHTML

As you know, XML is case sensitive: A tag defined in all uppercase letters needs to be written in all uppercase letters; a tag defined all in lowercase needs to be written all in lowercase. In XHTML, all tags are defined in lowercase. When writing XHTML 1.0 documents refer to the HTML 4.01 specification for information about specific tags and arguments, specificaly the "Index of Elements" and the "Index of Attributes." Any examples you see will remain nearly the same when converted to XHTML, except that you will need convert everything to lowercase.

For example, the following tag is fine for HTML, but it is wrong in XHTML:

       <Body BGColor="#00ff00"> body text </Body>
In XHTML, the tag should read:
       <body bgcolor="#00ff00"> body text </body>

The HTML you're used to working with every day is case-insensitive. If you want to prepare yourself for a standard-compliant world, it's a good idea to begin writing your HTML documents make tags and arguments lower case for easy future conversion to XHTML. When in doubt, get rid of the caps.

Much like its parent XML, XHTML requires that you close all of your tags. It's something that we're used to doing already, but the tricky part comes in when you have to use closing tags that are optional in HTML -- when was the last time you used </li>? Every open tag in your XHTML document needs to be accompanied by a closing tag.

So, a paragraph in your document cannot look like this:

       <p>This is a bad paragraph!

Instead, use a closing tag, like this:

       <p>This is a good paragraph!</p>

You must remember to close every tag! Every <li> needs a </li> and every <td> needs a </td>. The same goes for all standard HTML tags, even the ones which feel awkward, like <img> and <br>. Fortunately, there is a shortcut for closing these tags that don't usually need to be logically closed. The shortcut is to add a close-command slash at the end of the tag to turn it off.

For instance, there's no need to type:

       <br></br>

In XHTML, the tag looks like this:

       <br />

Let's take a look at a familiar task, like the placement of an image. In HTML, an image placement looks like this:

       <img src="logo.png" alt="The Logo of My Company">

In XHTML, it would be changed to:

       <img src="logo.png" alt="The Logo of My Company" />

This shortcut has been accepted as the de facto standard when using tags that don't normally appear with closing tags when used in HTML. While something like a <hr></hr> set of tags is valid in the XML world, they can often confuse browsers that were written without XML in mind. So, just use <hr /> to be safe, and don't forget the space before the / character. This rule applies to all tags that you wouldn't normally close if you were writing in HTML 4.01.

next page»


Dynamic HTML  

Frames  

HTML Basics  

Stylesheets  

Tables  

XML  

Javascript  

Database Connections  

Intro To Perl  

HTML 4.0  

User Blogs

Screen Shots

Latest Updates

Contact Us

Valid HTML 4.01!
Valid CSS!

Breadcrumb

© ElectricType
Maintained by My-Hosts.com
Site map | Copyright | Disclaimer
Privacy policy | Acceptable Use Policy
Legal information.