This is part 2 of the transition article. If you haven’t read part 1, I suggest you do it before reading this.
So what we have at this point is a valid HTML page, that’s starting to look a bit cleaner and looking more like a valid XHTML page.
Let’s continue with the transition.
I haven’t seen many attribute minimalizations except for pages made with MS FrontPage. An attribute minimalization is something like this:
It is not allowed anymore and should be written out full, like this:
Also when you have an empty paragraph, you have to write it like this
<p></p> instead of just
Naming your tags
One of the attributes of HTML is the name attribute. It is used for anchors and form input. XHTML prefers the id attribute instead. With the id attribute, you can also define style to a specific container. There is however a difference between the two. The id attribute must be unique within the page. This means that a value of that attribute can only be used once on each page. Also the id attribute can not start with a number.
Before you start changing all your name attribures into id attributes, there is a catch. You can’t do this for forms. Forms need the name attribute to be able to send their fields. So it is best to use both id and name.
You might say, aren’t ampersands content and not layout or structure, so why do I need to change this. Well it is simple HTML uses ampersands to specify certain entities. Like <, > or ©. When you want to write a & you need to use &
The last thing you need to add is a document type, better know as a DocType. A doctype specifies what kind of document it is. You need this, when you want to validate your XHTML page, or for certain webbrowsers to know that it is in fact a XHTML page and not a normal HTML.
There are three kinds of doctypes: strict, transitional and frameset
I’m not going to discuss the last one.
The rules for a strict XHTML are even more ‘strict’ than for a transitional XHTML page. The points to a slow transition to XHTML that I’ve pointed out in this and the previous part, are to create a transitional XHTML page.
The doctype for XHTML transitional is this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
You need to add this at the top of your XHTML source code, above the opening
Well, that’s it, you now should have a valid HTML transitional page.
In part 3 I’ll explain some things that are good practice, but are not required.