Forum Moderators: open

Message Too Old, No Replies

Am I using the correct doctype?

         

Rightz

9:16 am on Jun 21, 2006 (gmt 0)

10+ Year Member



I am using css, js, tables, html and on a few pages php.

Is this the right choice for my doctype?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

or would this is better? I'm confused!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

or

simply:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

benihana

9:23 am on Jun 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



id go for the top one.

The last one is incomplete, and will cause rendering problems in some browsers.

kaled

9:47 am on Jun 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Generally, if your knowledge is such that you have to ask the question, you should use the transitional doctype.

If you omit the url, IE, and possibly other browsers will render the page in quirks mode. Many pages will render identically, the main difference is the box-model. In quirks mode, height and width define the outermost area (and include the margin, border and padding) but in standards mode, height and width define the dimensions of innermost area, i.e. the canvas in which text and/or images are rendered.

Think of it like a painting - when you specify a size, does it include or exclude the frame?

Kaled.

oxbaker

7:45 pm on Jun 21, 2006 (gmt 0)

10+ Year Member



thats a good way of thinking of it.

Rightz

2:19 pm on Jun 22, 2006 (gmt 0)

10+ Year Member



I've used

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

It works and looks fine on the pages But when I try to W3C validator it says it is not 'HTML 4.01 Transitional'.

What do I do now?

choster

2:42 pm on Jun 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Validation and "looking fine" are different beasts. All the latter means is that your web browser has made a pretty good guess as to what you intended. All the former means is that the code in the page conforms to the letter of a certain set of rules. In theory you could have a web page which validates and looks fine, but which is unusable and semantically bankrupt. But that's for a different thread :).

See post #2 for your answer.

wmuser

2:53 pm on Jun 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would go with first option

Rightz

4:20 pm on Jun 22, 2006 (gmt 0)

10+ Year Member



What do I do if it doesn't look right with option 1? Just rewrite all my pages?

kaled

6:08 pm on Jun 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would go with first option.

That is not the question. The question is what is right for someone else?

It is my understanding that the transitional doctype was defined specifically as an upgrade path. Since it is clear that existing code is being upgraded, why not use the right tool for the job?

If anyone out there can state one definitive advantage to using the strict doctype, I'll be impressed, however, in many cases, both will work identically.

Kaled.

encyclo

1:32 am on Jun 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are using tables for layout, then you should usually choose this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

If you have a full CSS-driven (table-less) layout, then you should usually choose this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

If you use the shortened transitional version without the URL, you will trigger "quirks mode" in modern browsers (IE6, Firefox, Opera...). See our library thread Quirks mode versus Standards mode [webmasterworld.com] for further information. In the long-run, it is a good idea to always use a standards-compliant mode in the browser rather than relying on the quirks-mode behavior which is a continuation of established rendering bugs in older browsers all long since disappeared from the scene.

The "full" transitional doctype will trigger an "Almost Standards Mode" in Firefox (and other Gecko-based browsers). The difference between "Almost Standards" and "Standards" relates to default line height and margin settings in tables, hence the recommendation to use transitional for tables-based layouts. You may find that the Strict doctype will work just fine too for a tables-based layout, assuming you have no deprecated markup on the page.

So the advantages of using HTML 4.01 Strict are that you ensure that you are using the full standards mode in all modern browsers, and that it will push you into using CSS rather than deprecated presentational markup in your document.

Of course, choosing the right doctype is just one step - making sure your document is error-free by using the HTML validator [validator.w3.org] is another vital step.

Rightz

11:08 am on Jun 23, 2006 (gmt 0)

10+ Year Member



With the

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

doctype, the height in the td tag isn't working. Its making the td a lot taller than needed. Should I be using a xhtml doctype instead?