Forum Moderators: mack

Message Too Old, No Replies

Doc Tag

someone told me but....

         

sara2

12:19 am on Apr 4, 2004 (gmt 0)

10+ Year Member



Hi, someone told me to put a doc tage in my pages, but they did not come back and tell me any details. What is a doc tag? And, do I need it?
Thanks!

[edited by: sara2 at 3:12 am (utc) on April 4, 2004]

sidyadav

1:34 am on Apr 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



sara2, welcome to WebmasterWorld!

Please note that URL drops are not allowed at WebmasterWorld, so remove it ASAP or it will get removed by a mod.

A doc-type declaration is a tag which you put on the top of your page/pages for it to validate as a valid XHTML/HTML document.

More information can be found here [google.com] - just look through the sites.

Sid

isitreal

4:55 pm on Apr 6, 2004 (gmt 0)

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



No, you don't need it. If you learn how to make your html error free, and are able to validate it in a validator like you find [validator.w3.org...] here, then using a doctype has a purpose. Saying your page is a valid doctype when it doesn't contain valid html is pointless.

The only thing a doctype will do is trigger non quirks rendering in Internet Explorer 6, but that has to be the full doctype, the two line one, with the url in it.

If you don't use a doctype your pages will render in quirks mode, all that means is that you won't get any surprises.

Check your pages on a few browsers, like opera, and www.mozilla.org and you will be fine.

HelenDev

10:52 am on Apr 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Saying your page is a valid doctype when it doesn't contain valid html is pointless.

I was always led to believe that not giving a page a doctype was very bad.

Isn't it better to have a doctype anyway, whether a page validates or not? Obviously the goal is to write valid code, but what about if you are working with 100s of pages which don't validate, and you haven't got a spare ten years to run them all through the validator?

grahamstewart

10:58 am on Apr 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd agree with Helen. Having a doctype is not meant to be a decalaration that your page is valid. It simply declares which version of html you are attempting to write your page in.

Having said that, you should make every effort to ensure your page is valid as it tends to improve cross-browser display, avoids confusing spiders and helps to future-proof the page.

isitreal

2:19 pm on Apr 9, 2004 (gmt 0)

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



declares which version of html you are attempting to write your page in

The problem comes when the person or program inserting that doctype doesn't know what the differences are between html versions, which is most of the time. It makes sense to use it if you have some idea of what that doctype supports and what it doesn't support, like closing all tags, upper/lower case html, frames, targets, type etc.

You can get this idea by creating a single valid page using the w3c html validator, then from that you can sort of tell what your actual HTML is, sort of anyway. This will at least tell you roughly what doctype your documents are closest to.

I'm not sure how browsers make these determinations, since most pages are just straight html, I'd guess they pretty much apply all the lowest common denominator for all the rules to a page, sort of anyway.