In XHTML, all tags must be lowercase
This is simple enough. Instead of using tags like <P>, <STRONG>, and <TABLE>, use <p>, <strong>, and <table>. Look at that! You’re 1/3rd of the way towards being an XHTML guru.
In XHTML, all tags must be closed
Again, something a good Web designer does anyway. But if you’re one the few people who still leaves <p> tags unclosed, now’s the time to start closing them.
Example of valid HTML:
<p>This is a paragraph
Equivalent in XHTML:
<p>This is a paragraph</p>
Tags that don’t contain data (like breaks, images, and horizontal rules) should also be closed in HTML. There’s no need to write an opening and closing tag, though. We can use the perfectly acceptable shortcut:
<!— Examples of properly closed XHTML tags -->
<!—Properly closed image -->
<img src="someimage.gif" alt="An image" />
<!—Properly closed break tag -->
<br />
<!—Properly closed horizontal rule -->
<hr />
<!—Properly closed image -->
<img src="someimage.gif" alt="An image" />
<!—Properly closed break tag -->
<br />
<!—Properly closed horizontal rule -->
<hr />
In XHTML, tags must be properly nested
Here’s another area where good HTML coders are properly writing valid XHTML, even if they’re not aware. In HTML, the following code might display exactly as you intended:
<strong>
<em>
Here’s some bold and italicized text
</strong>
</em>
<em>
Here’s some bold and italicized text
</strong>
</em>
Although this might work, it’s not “good” code. And for the purposes of this article, not valid XHTML either. To complete your XHTML training, simply make sure your tags are properly nested:
<strong>
<em>
Here’s a valid XHTML version of bold italicized code
</em>
</strong>
<em>
Here’s a valid XHTML version of bold italicized code
</em>
</strong>
XHTML wrapup
XHTML is just cleaner HTML—tags are consistently lowercase, all tags are closed, and tags are properly nested. Making your pages valid XHTML is a piece of cake.






No comments:
Post a Comment