Tags/rules that change between html and xhtml

The main difference between html and xhtml is that xhtml is just an advanced way of writing xhtml. Xhtml is easier to maintain then html, certain rules such as all attribute names most be lower case and all elements have to have a closing tag. Since there is more guidelines to follow in xhtml it is easier to fix, on the other hand html guidelines are more broad and takes more time to isolate problems. Xhtml is different and more advanced then html because of its separation of presentation from structure, improved accessibility features, improved internalization features and improved document rendering.

10 examples of common tags and elements that changed

  1. All tags most be in lower case form = <FONT>à<font>
  2. All most be properly nested in right order to what its pertaining to =

Html à <p><b><font color="red">Your Text</p></font></b>

Xhtmlà<p><b><font color="red">YourText</font></b></p>

3. All tags most be closed in xhtml unlike html where some are left open.

html <br> xhtml <br></br>
<img> <img></img>
<hr> <hr></hr>

4. Image tag needs a to be close at the end with a space.

Html <img src="myimage.gif" alt="My Image" width="400" height="300">
xhtml <img src= "myimage.gif" alt="My Image" width="400" height="300" />

5. All documents must have a doctype at the top of the page which declares what type of code you are writing for example html, xhtml, strict, loose, etc..

!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 StrictEN" "">

6. All documentation must be properly formed. Meaning the format of the page has to be in a certain order to be considered xhtml instead of html.

Order of a transitional xhtml doctype.

<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 TransitionalEN" "">
<title>Page Title</title>

7. Avoid line breaks and multiple white space characters within attribute values. These are handled inconsistently by users.

8. Use both the lang and xml:lang attributes when specifying the language of an element. The value of the xml:lang attribute takes precedence.

9. The named character reference &apos; (the apostrophe, U+0027) was introduced in XML 1.0 but does not appear in HTML. Authors should therefore use ' instead of &apos; to work as expected in HTML 4 user agents.

10. Don't include more than one isindex element in the document head. The isindex element is deprecated in favor of the input element.

5 examples of common attributes and line code that changed

1. All XHTML attribute names should be in lower case.
Width="100" and WIDTH="100" are wrong; only width="100" is correct.

2. All attribute-value pairs should be quoted.
width=100 is wrong; it should be width="100" or width='100'.

3. HTML supports certain attributes which have no values. Examples are noshade which appears in the <hr noshade> tag. XHTML does not allow such empty or compact attributes. The compact attributes generally found in HTML are compact, nowrap, ismap, declare, noshade, checked, disabled, readonly, multiple, selected, noresize and defer. They should always have a value. In XHTML this is done by giving the attribute name itself as the value.

noshade becomes noshade="noshade"

checked becomes checked="checked"

4. The name attribute is deprecated and will be removed in a future version of XHTML and the id attribute will take its place. So, for HTML tags that need the name attribute, an id attribute should also be specified with the same value as that for name.
<frame name="myFrame" > à <frame name="myFrame" id="myFrame" >

5. All & (ampersand) characters in the source code have to be replaced with &amp;,
which is the same code. This change should be done in all attribute values and URIs.

Bee&Nee à Bee&amp;Nee.

<a href="my.asp?action=read&value=1">Go</a> à

<a href="my.asp?action=read&amp;value=1">Go</a>.

3 good web sources for using html and xhtml

1. – provides a tutorial on converting from html to xhtml.

2. – provides information of html, xhtml, etc… and contains validators

3. – provides you with solutions to basic xhtml and html problems