Forum Moderators: open

Message Too Old, No Replies

Doctype for mongrel site

working on site that currently has no Doctype

         

Robert Charlton

6:33 am on Jun 9, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I'm optimizing a site with pages that currently have no Doctype declaration. It seems to be mostly messy HTML 3.2 with some tags proprietary to IE. The client currently has no budget for a new site, and I'm trying to patch things up as best I can in limited time until they do a redesign in 6 months or so.

I'm adding some CSS, closing some paragraphs, changing </br> to <br /> and some center tags to divs, etc, and I'm assuming that I should add the HTML 4.01 Transitional Doctype, with no w3c.org url in the tag, as in:

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

The quandry, though, is that I'm not really going to run this through a validator... Until the redesign, there's no time or budget for it and the code is better than it was before. I'm checking it on the current major browsers plus Netscape 4.

I assume, though, that we're still much better off with the Doctype than without. Would appreciate any comments....

grahamstewart

7:48 am on Jun 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It seems to be mostly messy HTML 3.2 with some tags proprietary to IE

Well according to the w3c list of valid doctypes [w3.org], the correct doctype for html3.2 is..


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

The doctype you suggest is incomplete so it will place the browser into quirks mode. This also happens if you miss out the doctype entirely so I'm not sure if there is any benefit in including it (especially if you don't plan to validate).

Sinner_G

7:49 am on Jun 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just a small note to say I would do the same if I were you. A doctype is always better than none, I guess in your case you have no choice but transitional and the w3 url is not really useful as no browser (AFAIK) uses it anyways.

grahamstewart

7:54 am on Jun 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



w3 url is not really useful as no browser (AFAIK) uses it anyways

Actually unless you specify this URL the doctype is incomplete and the browser (IE/Opera/NN) renders in quirks (buggy) mode. To get it to render in standards-compliant mode you must include the url.

Robert Charlton

4:42 pm on Jun 9, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



To get it to render in standards-compliant mode you must include the url.

I remember a discussion quite a while back (couldn't find it by searching) where a lot of people who included the url had problems that were solved by dropping it, though, if none of the browsers uses it, I don't understand why.

Checking source code, I see that WebmasterWorld uses the Transitional Doctype without the url.

Sinner_G

7:01 pm on Jun 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



HTMLhelp [htmlhelp.com] states the following about the HTML 4.01 Transitional doctype:

Newer browsers such as Internet Explorer 5 for Mac, Netscape 6, and Mozilla use a standards-compliant rendering for HTML 4.01 Transitional documents that include the URI of the DTD in the DOCTYPE. These browsers use a "quirks" mode to emulate rendering bugs in older browsers if the URI is omitted:

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

To me this implies that other browsers don't have a quirk mode.

tedster

7:04 pm on Jun 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could also say that other browsers are ONLY quirks mode

grahamstewart

10:17 pm on Jun 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



this implies that other browsers don't have a quirk mode

Sounds like HTMLHelp is a little out of date. Quirks mode appears in all current versions of IE, not just IE for the Mac.

Heres Microsofts explanation of the 'doctype switch' [msdn.microsoft.com].
Heres a great article from AListApart [alistapart.com] about it.

a lot of people who included the url had problems that were solved by dropping it

Yup, these people were seeing for the first time what their page looked like when rendered as 'standards-compliant'.

It all looked broken because the browser was using the proper box model and layout, rather than the old MS buggy one. So they had a little panic and switched back to a design that only works well on MS browsers (and browsers that have deliberately emulated the MS bug).

Including the doctype does not CAUSE problems, it solves them. But it can mean some extra work to make your code standards compliant.

Checking source code, I see that WebmasterWorld uses the Transitional Doctype without the url.

Yeah, but it also uses font tags! Don't let the code for this page be your guide. :)

g1smd

10:59 pm on Jun 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>> I'm optimizing a site with pages that currently have no Doctype declaration. <<

I would add the !DOCTYPE to it:

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

as well as these two meta tags in the <head> section:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Language" content="en-gb">

using the correct language (ISO 639) and country (ISO 3166) codes.

Make sure every page has a relevant:

<title> Title Goes Here </title>

and a good:

<meta name="Description" content=" Describe the Page "

and then check the pages at: [validator.w3.org...] for any errors in the code.

It isn't widely used but I would still add a:

<meta name="Keywords" content=" some keywords here ">

>> changing </br> to <br /> and some center tags to divs <<

You should only use a closing / in XHTML documents. With HTML 4.01 adding those will cause your code to fail the validator. Don't try to just add an XHTML declaration instead, just to try to get it to work, as the code really does have to be perfect in order for XHTML to work, and even then there are numerous issues with it (see recent thread where this and MIME types was mentioned).

I don't know why you are changing from center to DIVs, that sounds like unnecessary work to me.

>> The quandry, though, is that I'm not really going to run this through a validator <<

You should test every page. It isn't worth doing the work unless you are going to test it in the validator.

>> I'm checking it on the current major browsers plus Netscape 4. <<

Validate it instead. That would be a better use of your time.

>> I assume, though, that we're still much better off with the Doctype than without. <<

With a short DOCTYPE, the document will still be rendered in Quirks mode. You can't go for standards mode unless you fully validate everything and add a long DOCTYPE complete with URL in it. However, I never do that last bit; i have always used only the short DOCTYPE without URL.

It is good to see you tidy up the code, but use the validator to give you a list of what needs fixing first.

Robert Charlton

7:32 am on Jun 10, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Thanks for all the good information and links. The Microsoft article, in particular, lays out all the possible combinations very clearly.

Yeah, but it also uses font tags!

Yeah, but the site I'm working on uses font tags too! No way I'm rebuilding it for free. ;)