Forum Moderators: open
Aren't they just there for pernickity validation?
If it's just for that very reason then what if I run a page through a validation tool, get a 100% and then just delete the doctype line?
Or do search engines require this information? Are you penalised if you don't have the line at the start of every page?
After that, is it essential? The answer is probably no, it is not essential, however it is certainly good practice to have one. As Robin_reala has said, the main role for a "full" doctype, apart from for validation, is to trigger standards-compliance mode [webmasterworld.com] in modern browsers. Removal of the doctype in these circumstances is a bad idea because the rendering mode in the browser would be changed, and it could have negative consequences for the layout.
It's only the old static pages which I had created with the html package which sets a doctype at the start of everypage.
I guess I can just cut and paste the static files doctype into the php pages and all will be fine.
It just seems a waste to me. Why bother having a doctype if a) your pages have been tested and validated fine, b) SE's and browsers don't check for it. c) All pages load without any physical errors anyway!
Let's say you guys convince me it's a good idea to have the code. Is one set of string better than the other? Is it possible to use doctype to tweak a page such that browsers load the page faster, or make SE's more efficient?
How hard is it to put a DOCTYPE on every page? I mean, it's not something that most people know by heart, but one can be copied from the web in less than 20 seconds.
Without a DOCTYPE, of course, your page isn't actually HTML, but you shouldn't let that stop you. The same could be said for header elements -- I mean, if the user doesn't see the <h1> and <h2> elements, then what's the point? You might as well replace them with <font> elements instead.
For that matter, is there actually any point in validating your page at all? I mean, all browsers have a bit of error correction built in. Any one of the popular browsers can cope quite happily with interleving blocks, and will mostly guess what you intended in any case.
I'm just being lazy but it's a valid reason for being lazy if there is no good reason for having a doctype.
Just scanning a few sites out there:
Google doesn't have a doctype but Yahoo does.
Some major sites in my sector don't have a doctype but others do.
There doesn't seem to be any consistency here.
Not only that but some of the sites have:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Whilst others have 4.0
Is it the case that some webmasters have it in grained that their sites are not perfect if they don't have a doctype?
Google doesn't have a doctype
Google's code is optimised to be tiny. The code on their homepage is as small as it could possibly be whilst still working with pretty well every browser ever created.
Considering that they are getting hit *billions* of times per month, and that a single extra character therefore means extra gigabytes of bandwidth, a 120 or so byte DOCTYPE just doesn't look like such a great idea from a business perspective :-)
b) SE's and browsers don't check for it. c) All pages load without any physical errors anyway!
You may say that it only takes 20 seconds to copy but if I have hundreds of pages it's a lot of time.I'm just being lazy but it's a valid reason for being lazy if there is no good reason for having a doctype.
Just scanning a few sites out there:Google doesn't have a doctype but Yahoo does.
Some major sites in my sector don't have a doctype but others do.
There doesn't seem to be any consistency here.