Forum Moderators: open

Message Too Old, No Replies

Doctype help!

I don't know which doctype to use ; (

         

sinclasc

3:43 pm on Nov 9, 2005 (gmt 0)

10+ Year Member



Hi guys.
My site is built mainly around an asp template, and as such all files are .asp . There are several sections of pasted js (google ads, calculators and the like) on various pages.
Which doctype and content-type should I use? It currently doesn't validate as any type (tried a few doctypes with the WC3 validator).
Any help appreciated!

asquithea

3:56 pm on Nov 9, 2005 (gmt 0)

10+ Year Member



Opinions differ as to whether you should go with Strict or Transitional for an existing webpage. Here's my take:

If you aren't willing to do any work to make the page valid, don't even worry about it -- the DOCTYPE is the least of your worries.

If you're interested in writing valid, portable code, go with a Strict DOCTYPE, and validate using the W3C tool. Fall back to Transitional only if you can identify the features of your webpage that force you to do so and can describe the effects it will have on rendering in IE, Opera, Safari and Firefox.

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

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

encyclo

4:10 pm on Nov 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Going towards a strict doctype is good in the medium to long-term, but with an existing site built with "tag soup" then you are probably best working towards validation with a transitional doctype first. I would start with this first:

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

If you try the above the page and the page layout becomes adversely affected, use this instead:

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

The second doctype (without the link to the DTD) will ensure that the browser remains in "quirks mode".

Once you have your doctype in place, validate against it and start working through the errors one by one from the top. Don't be disheartened if the validator says there are hundreds of errors - problems can cascade so fixing earlier errors can often solve subsequent ones.

If you use the second doctype listed above, once you have fixed the errors in the page, it is a good idea to revert to the first one (which triggers standards-compliance mode in modern browsers) and fix any display bugs. After that, you can start simplifying your markup and introducing more CSS to lighten up the page and prepare for a move to validation against a strict doctype.

Good luck!