Forum Moderators: open

Message Too Old, No Replies

once again: !DOCTYPE

         

PsychoTekk

9:58 am on Jul 17, 2002 (gmt 0)

10+ Year Member



i know this topic has been discussed very often but
after reading many threads and looking at all the links i
still have one question left.
the documents in question validate in
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
as well as in
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

so my question is, should i take the HTML 4.0 or 4.01 declaration?
what are the (dis)advantages?
it doens't matter if spiders would like the one or the other way better
since the documents are error pages.

Nick_W

10:13 am on Jul 17, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd say it doesn't matter one way or the other. But for the sake of forward compatibility choose the 4.01

In fact, why don't you see if they validate as xhtml transitional? I'll be they do....

Nick

PsychoTekk

10:42 am on Jul 17, 2002 (gmt 0)

10+ Year Member



forward compatibility sounds good - i declared them as HTML 4.01 now :)
thanks

bird

3:34 pm on Jul 17, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Note that both declarations are NOT formally correct, unless you add the path to the DTD to the end:

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

If you omit that part, then you could just as well leave the declaration away altogether, as most browsers will then switch to "quirks mode", and display the page in whatever ways they please.

PsychoTekk

5:08 pm on Jul 17, 2002 (gmt 0)

10+ Year Member



thanks bird, i'll include that at the next opportunity

PsychoTekk

5:58 pm on Jul 17, 2002 (gmt 0)

10+ Year Member



i'm surprised - the errordocuments used by the IBM-PROXY-WTE-US/3.6 cacheservers
of the german isp t-online just contains <!doctype html public "html2.0">
and the apache uses <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">, at least
by default - so these tags are absolutely pointless and just a waste of space?
i can't believe that an open source project like apache adds a useless
tag to its errordocs...
i think i'm gonna add the outstanding info to all my html docs soon :)

pat_s

6:15 pm on Jul 17, 2002 (gmt 0)

10+ Year Member



I'm confused as well. A page will validate without the URI.

mbauser2

7:40 pm on Jul 17, 2002 (gmt 0)

10+ Year Member



Time to talk SGML again...

I'm confused as well. A page will validate without the URI.

That's because bird was incorrect. The system identifier (the part that's a URI) is optional in an SGML declaration when the external identifier indicates the language is "PUBLIC" (as HTML's formal public identifier does with the word "PUBLIC").

(The system identifier can, in fact, be changed by the document author to point to any location containing a copy of the DTD for the SGML language used.)

The SGML declaration used by Apache is a valid declaration for HTML 2.0 as defined by RFC 1866. It even appears in the examples there.

That t-online public identifier is shadier. I think it's valid as a "public identifier", but it's definitely not valid as a "formal public identifier" (it doesn't identify the owner or public language of the DTD), which could make things difficult for a real SGML parser.

bird is (unfortunately) correct when pointing out that browsers will render pages differently if they've changed or omitted the system identifier. That was just a damn stupid decision on Microsoft's part, but we're stuck with it. If you don't like quirks mode, you need to include the system identifier.

moonbiter

7:59 pm on Jul 17, 2002 (gmt 0)

10+ Year Member



I'm confused as well. A page will validate without the URI.

The reason the URI is there is because, according to the W3C, it "allows user agents to download the DTD and any entity sets that are needed ..." They are not required for validation.

The first part of a DOCTYPE is the DTD Name:

<!DOCTYPE html [b]PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"[/b]

and is used by a validator to tell it what DTD to use to do it's job. An HTML validator will have DTD name as part of it's own catalog, so it doesn't need the URI to look up the rules -- it already knows them.

However, if a "user agent" or validator doesn't have the DTD Name in it's catalog, that's where the DTD Location comes in. This is the second part of the DOCTYPE:

[b]"http://www.w3.org/TR/html4/loose.dtd">[/b]

and it is a URI that tells the validator where to look to get the rules that the document is supposed to conform to.

So, all a validator does is look at a set of rules, look at your document to see if it obeys those rules, and then nag at you if your document doesn't.

Most of the better validators know the PUBLIC rules (standards) by their name, but sometimes they don't, and so they have to go and look it up on the internet. The DTD Location gives them the means to do so. But it isn't required for validation.

Of course, that whole "modes" thing with the browsers is what confuses the issue: basically, a doctype without a URI is will throw a browser into "quirks" mode, so you might not get the result you expect if you leave the URI out. So while technically it is not required to have the URI there, if you don't have it you might as well not have a DOCTYPE at all as far as these particular "user agents" are concerned.

Some references:

[htmlhelp.com...]
[alistapart.com...]
[xmlwriter.net...]

Someone please correct me if I am wrong. :)

bird

8:38 pm on Jul 17, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's because bird was incorrect. The system identifier (the part that's a URI) is optional in an SGML declaration

Guilty as charged! ;)

However, my conclusion still stands, as confirmed by moonbiter:

So while technically it is not required to have the URI there, if you don't have it you might as well not have a DOCTYPE at all as far as these particular "user agents" are concerned.

Understanding what this means, I can only reccommend: Never use a doctype declaration without including the DTD URI, or face the prospect of being confronted with highly inconsistent browser behaviour.

pageoneresults

9:01 pm on Jul 17, 2002 (gmt 0)

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



> Never use a doctype declaration without including the DTD URI, or face the prospect of being confronted with highly inconsistent browser behaviour.

Unfortunately, the URI can interfere with CSS. I had the experience and Brett made a suggestion to drop the URI, which I did and it corrected the issue with the CSS and Absolute Positioning. If you look at the source code for the forums, you'll see that the URI is also absent.

I haven't seen any Quirks without the URI and I've been using it that way for at least 6 months on a new site and longer with older sites.

> If you omit that part, then you could just as well leave the declaration away altogether.

Can't omit the DOCTYPE if you want to validate, its got to be there if I'm not mistaken.

moonbiter

9:28 pm on Jul 17, 2002 (gmt 0)

10+ Year Member



Can't omit the DOCTYPE if you want to validate, its got to be there if I'm not mistaken.

Note that you can have perfectly well-formed HTML without it being valid. With the W3C's HTML Validation Service [validator.w3.org] you can validate your HTML without a DOCTYPE by specifying a document type during the input process. You'll get a big yellow warning box saying how horrible you are for not having a valid DOCTYPE, but then it will go on and validate your page for you. ;)

pat_s

1:20 am on Jul 18, 2002 (gmt 0)

10+ Year Member



I hope this is still on topic - Suppose..just suppose...your HTML won't validate, because you're still using some attributes that are no longer allowed, like "background". Are you better off using a doctype or not? I've got a doctype on all my pages of all my sites..I think. Pretty much anyway. I put them there before I really understood what they were for. People said you should have one, so I started adding them. But I'm not close to validating on a lot of the pages in question because of things like the above mentioned no-no. Not only have I not found time to make all necessary changes, but I'm having a hard time making myself change over when I still get some NN4x visitors. So, if a page isn't valid, is a doctype a plus or a minus or neither?

moonbiter

1:50 pm on Jul 18, 2002 (gmt 0)

10+ Year Member



So, if a page isn't valid, is a doctype a plus or a minus or neither?

I don't know that there is a definitive answer to this. IMHO, if you are knowingly not producing valid pages or have non-valid pages that you have no intention of changing, there is little point to having a DOCTYPE. Current browsers don't care all that much, and future browsers that do care are likely to choke on or ignore your invalid markup anyway.

If you are using elements/attributes from versions of HTML older than 4, but are otherwise have well-formed markup, then use the DOCTYPES for those versions:

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

Your example, background, is a real attribute in HTML 4.01 (even if it is a deprecated) and would be valid according to the transitional DOCTYPE:

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

If you are using proprietary IE or Netscape attributes and elements (like blink and marquee, for which you should be crucified ;)) then I wouldn't put a doctype in. Sure, there are doctypes for some of these, and the W3C validation service even recognizes some of them (see [validator.w3.org...] but what's the point, really.

Validation is not a moral issue -- you are not bad or evil if the markup you write is invalid. It is simply a way to ensure that you write clean markup, troubleshoot problems, and provide forward compatability. All IMHO, YMMV. :)

p.s., if you really want to have your nonstandard code validate, you could create your own DTD:

[htmlhelp.com...]

But again, what's the point of that?

pat_s

2:38 pm on Jul 18, 2002 (gmt 0)

10+ Year Member



The only really invalid piece of code I intentionally use anywhere is the topmargin, leftmargin, etc. I know it's not valid and has never been valid, but it works in more browsers than CSS does and much more reliably. I usually include the CSS, too, in anticipation of changing over eventually. I always use HTML 4.01 Transitional. That seemed safest, but the whole thing is looking more and more like a minefield every day. :)

papabaer

4:10 pm on Jul 18, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A long time ago I worked in a truck repair shop, once a customer came in looking for an #1156 light-bulb. The bin that held the #1156 bulbs was empty, but the neighboring bin held several #1157 bulbs. Looking at the burned out #1156 in his hand, and then pointing to the #1157 bulbs he asked, "Will that work?" Can you guess the answer?

<!DOCTYPE> + URI = good form. Use it as your foundation as you build and you will not have to worry about quirk mode or standards mode.

pageoneresults

4:17 pm on Jul 18, 2002 (gmt 0)

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



> <!DOCTYPE> + URI = good form.

Tell that to Opera! ;)

With the URI, there was a spacing problem at the tops of pages. Without it, the spacing problem was gone. Haven't tested it since then which was a couple of months ago.

I might just give it a try to see if the bug has been corrected. All other browsers displayed the pages properly with the URI except for Opera.

papabaer

4:25 pm on Jul 18, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Opera is just rendering W3C standards. All you need to do is write CSS that accounts for this; it's very simple to do... and correct.

By accepting "quirks mode" you are never really "seeing" HTML elements as intended. When you include the URI (as you build) you simply (very simply!) create your styles to present your page elements as desired.

papabaer

4:29 pm on Jul 18, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I might just give it a try to see if the bug has been corrected. All other browsers displayed the pages properly with the URI except for Opera.

It is definately NOT a bug. Opera is strict where others are lax.

HTML automatically adds an extra blank line before and after a heading.

Headings for example: Opera will include a spacing at the beginning (top) as well as the end (bottom) of headings.

h1,h2 {margin-top:0;} will allow headings to render the same in Opera as they do in IE.

pageoneresults

4:40 pm on Jul 18, 2002 (gmt 0)

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



papabaer, the spacing issue had to do with an include that contains the graphic navigation structure for the site. I believe you assisted me with the H1 issue a few months ago and that was corrected.

What was happening is the URI was causing a 12px gap between the top of the page and the beginning of the <div> that contains the navigation include. That <div> is set to left:0px; and top:0px;

All the other browsers we tested in when the URI was present worked fine. When viewing in Opera, the gap appeared. Brett replied to a topic I had posted in discussing the issue. I can't recall the exact response but the fix was to eliminate the URI which eliminated the problem.

papabaer

4:47 pm on Jul 18, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unless you assign padding:0; to the body CSS, Opera will render an 8px "space" for the body element. That MAY have caused the display variance.

Once again, Opera is correct in this. Others use body {margin:0;} (incorrectly), you may want to try it by adding body {padding:0;} and then set your divs.

You can safely use the following:

body {
margin:0;
padding:0;
}

pageoneresults

5:23 pm on Jul 18, 2002 (gmt 0)

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



Thanks papabaer, got your stickys too! I'm going to correct this within the next couple of days.

On a side note, you are absolutely the best resource for all things CSS. Maybe the W3C should hire you and tedster for some consulting work! ;)

papabaer

5:38 pm on Jul 18, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



LOL! :)

I think the entire community here at Webmaster World is the best resource for CSS and everything else!

pageoneresults

2:13 am on Jul 19, 2002 (gmt 0)

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



> entire community

Agreed!

Just added the URI and hadn't even had a chance to view in Opera when I saw a problem in Moz. I'm using...

Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530

I have a set of <div>'s that contain a remote rollover effect within the navigation structure. By remote, I mean there is a third image involved with the rollover state. That set of <div>'s ended up moving down by about 5px or so and appeared to be partially behind another image. Hard to explain, but there is an issue.

The <div>'s are absolutely positioned and there are no other unusual declarations. They typically look like this...

div.globe{position:absolute;left:148px;top:0px;width:183px;height:183px;}

Yes, I know, shorthand, shorthand! Haven't had the time to really hunker down and tackle that one yet. So, where could my problem be now? I did add the padding:0px; to the body rule as suggested. I'll leave that there for Opera. Now what?

So I'm back to the short doctype for now. I see many sites that use the shortened version and I can only guess they use it due to various issues like these.

papabaer

3:11 am on Jul 19, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



there is a third image involved...

img.myStyle {display:block;} or inline? Don't forget that if you are using images that have not been politely instructed to behave as block elements, they will be subject to all the niceties assigned to inline text. There are instances where this could cause display issues. Try adding a 1px solid black border to your div and look for any distortion that the image(s) may produce.

moonbiter

2:27 pm on Jul 19, 2002 (gmt 0)

10+ Year Member



Once again, Opera is correct in this. Others use body {margin:0;} (incorrectly), you may want to try it by adding body {padding:0;} and then set your divs

Note that this is not strictly true. Opera just chooses to make the default indentation of text from the edge of the viewport the body element padding. Mozilla and MSIE choose to make the default indentation of text from the edge of the viewport the body element margin.

Both are correct implementations, however, because the outermost element of the viewport is not the body element but the root element of the document -- in the case of web pages the html element.

This can be easily demonstrated by placing a border on the body element and playing around with the padding and the margins of the element.

So, as papabaer suggests, be certain to specify both body {margin: 0px; padding: 0px} to zero out your margins.