XHTML Strict 1.0 Basics
List of Basics:
- All Tag Letters in lower case. For example: <td> rather than <TD>
- All Tags should be closed, especially these:
- <br> should be: <br />
- <hr> should be: <hr />
- <img> should be: <img --other stuff-- />
- <input> should be: <input --other stuff-- />
- img tag should have an alt attribute. For example: <img src="images/test.gif" alt="test" />
- Tags should be closed in order they are opened. For example:
<p><span></p></span> <--- Wrong!
<p><span></span></p> <--- Correct!!!
XHTML Strict 1.0 Tag Attributes
<table>:
The "align" and "bgcolor" attributes of the table element are not supported in XHTML 1.0 Strict DTD.
Possible workarounds:
You can use inline style elements or a class from a CSS file (Cascading Style Sheet).
For example:
<table style="text-align:center;margin:0 auto 0 auto">
<table style="background-color:blue">
<table class="table-bg">
<tr>:
The "bgcolor" attribute of the tr element are not supported in XHTML 1.0 Strict DTD.
Possible workarounds:
You can use inline style elements or a class from a CSS file (Cascading Style Sheet).
For example:
<tr style="background-color:blue">
<tr class="tr-bg">
<td>:
The "bgcolor", "height", "width", and "nowrap" attributes of the td element are not supported in XHTML 1.0 Strict DTD.
Possible workarounds:
You can use inline style elements or a class from a CSS file (Cascading Style Sheet).
For example:
<td style="height:30px;width:50%">
<td style="width:100%">
<td style="width:30px">
<td style="text-align:center;margin:0 auto 0 auto">
<td style="text-align:right">
<td style="background-color:blue">
<td style="background-color:#be12ff">
<td class="td-bg">
<td id="cell-bg">
<td style="white-space:nowrap">
<p>:
All "presentation attributes" of the p element are not supported in XHTML 1.0 Strict DTD.
<div>:
The "align" attribute of the div element is not supported in XHTML 1.0 Strict DTD.
Possible workarounds:
You can use inline style elements or a class from a CSS file (Cascading Style Sheet).
For example:
<div style="text-align:center;margin:0 auto 0 auto">
<div class="div-class">
<font>:
The <font> tag is not supported in XHTML 1.0 Strict DTD.
Possible workarounds:
You can use the <span> tag with inline style elements or a class from a CSS file (Cascading Style Sheet).
For example:
<span style="font-size:medium">
<span style="font-size:12pt">
<span style="font-size:larger">
<span style="color:red"> <---text color will show as red
<span class="title">
<span class="tiny">
<img>:
The "align", "border", "hspace", and "vspace" attributes of the image element are not supported in XHTML 1.0 Strict DTD.
Possible workarounds:
You can place this line in a CSS file (Cascading Style Sheet) so no borders are displayed around images.
img {border:none}
Mozilla Firefox and the alt Attribute
If you use the alt attribute in Firefox on images and image maps the text will not show on mouse-over as in other browsers.
Firefox uses the alt attribute the way it is meant to be used, like an alternative text if the image will not load, not as a mouse-over text.
Firefox does support mouse-over comments on images or image maps if you use a title attribute in the <img> tag.
E.g. <img src="image.gif" alt="bla" title="bla bla bla" />
<blockquote>:
The <blockquote> tag is supposed to contain only block-level elements within it, and not just plain text.
To validate the page as strict XHTML, you must add a block-level element around the text within the <blockquote> tag, like this:
<blockquote>
<p>here is a long quotation here is a long quotation</p>
</blockquote>
Note: The blockquote element creates white space on both sides of the text.
BLOCK LEVEL HTML ELEMENTS:
<blockquote>
<div>
<form>
<ol>
<p>
<table>
<ul>
Getting Ready for XHTML Strict 2.0
There are a couple of things that can be done now to get your code ready for XHTML 2.0:
- change <b> to <strong>
- change <i> to <em>