Forum Moderators: open

Message Too Old, No Replies

<!doctype> - is it worth using?

         

Crazy_Fool

7:58 pm on May 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i've never (knowingly) used a doctype tag on my html code. it all displays perfectly well without one, so why bother using it?

Nick_W

8:04 pm on May 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



well you'd be a crazy fool not to ;) (...oh dear) if you write Xhtml. It's part of the standard and the new browsers may missinterpret your page without it.

Also, you'll trigger 'quirks mode' in IE6 without it being the first line which will mean your css widths will be missunderstood.

Nick

papabaer

8:05 pm on May 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello Crazy_Fool,

Good question, hot topic! Lot's of opinions to be sure....

I am firmly rooted in the <!doctype> camp. While before "Standards" doctype was not "crucial," and some would argue that it is still not, the reasons FOR using a doctype are becoming more and more important.

I'm sure will here LOTS of viewpoints here... it's all good!

moonbiter

8:13 pm on May 22, 2002 (gmt 0)

10+ Year Member



so why bother using it?
  1. So you can write valid html
  2. So you can validate that you are writing valid html
  3. So you have some control over how the browser renders your html
  4. Because all of the cool kids are doing it ;)

Xoc

8:18 pm on May 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The DOCTYPE tells the browser what version of HTML you are coding to. Some of the later browsers actually look at that to determine how they are supposed to render your HTML, since essentially the rules changed between different versions. Also, a validator looks at the DOCTYPE to determine which DTD (Document Type Definition) it is supposed to validate the HTML against.

diddlydazz

8:23 pm on May 22, 2002 (gmt 0)

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



<<-- 1.So you can write valid html
<<-- 2.So you can validate that you are writing valid html

You shouldn't need a validator to tell you about your code ;)

dazz

pcguru333

8:30 pm on May 22, 2002 (gmt 0)

10+ Year Member



Ditto what moonbiter said.

Also 'THE POWERS THAT BE' are trying to influence a change on the web toward well-formed webpages. If they get the browser developers to make browsers less and less 'forgiving' then it is in our best interests the learn xhtml, thus the DTD 'Transitional' for this learning period.

Also XMl is up and coming, XHTML follows XML rules for well-formedness. While XML doesn't require a DTD it does require well-formedness or it won't parse. Using a DTD in XHTML helps to validate your pages for well-formedness.

Having worked in multiple areas of IT I can say that changing gears like using XTHML with DTDs is in your best interest to stay on top.

ergophobe

8:34 pm on May 22, 2002 (gmt 0)

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



In another thread, someone mentioned that if you have your <? xml tag *before* the DOCTYPE, this triggers quirks mode on IE6. Anyone know more about this? Since this is the standard order (at least in W3C docs), this seems strange.... that of course does not make it incorrect.

Tom

digitalghost

8:38 pm on May 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You shouldn't need a validator to tell you about your code

That validator comes in quite handy. I suppose if you can just pick up a book and read it and then start cranking out perfect code then a validator would indeed be useless.

Most of the experienced coders I know use debugging programs, validators, syntax checkers, etc. Besides, that W3C validation button looks so cool...

DG

Nick_W

8:43 pm on May 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In another thread, someone mentioned that if you have your <? xml tag *before* the DOCTYPE, this triggers quirks mode on IE6. Anyone know more about this?

That was me I think! Your pages will still validate perfectly well with the doctype first then the xml declarations.

IE5 missinterprets some pretty key css concepts and 6 is much more compliant so theý had a little worry over how to satisfy people that had whole sites full of carfully balanced pages that took into account ie5's 'quirks' and decided that 'standards' mode would only be triggered if there was a doctype on the first line.

Nick

ergophobe

8:49 pm on May 22, 2002 (gmt 0)

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




was a doctype on the first line

That's the part I didn't know. So will IE7 have "double quirks mode" which will trigger quirks in IE6 (because DOCTYPE is on the second line) and not in IE7 (because code is valid XHTML Strict....


You shouldn't need a validator to tell you about your code

You shluodn't nede a spellign dictionary to tell you how to spell byut someitmes when you go fast, you make mistake.

Tmo

papabaer

10:04 pm on May 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ergophobe,
You shluodn't nede a spellign dictionary to tell you how to spell byut someitmes when you go fast, you make mistake.

Great analogy! ;)
I no I knead a spell chequer awl the thyme!

Lot's of great reasons for using a <!doctype> listed here, including consistancy: I find using a <!doctype> is the first step towards this goal. Sure, there are other things to watch, but using a <!doctype> tells the browser "like it is." ;)