Welcome to WebmasterWorld Guest from 54.205.96.97

Forum Moderators: incrediBILL

Doctype statement in todays websites ?

   
7:51 am on Jan 22, 2013 (gmt 0)

5+ Year Member



Just wondering which is the best Doctype statement to use for the average website these days?

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

or

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

Thanks
8:20 am on Jan 22, 2013 (gmt 0)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I'd go for <!DOCTYPE html>
But new stuff I make is nowadays in polyglot (x)HTML5 anyway, never done HTML4.01 myself, always used xhtml during the era html4.01 was popular...
9:13 am on Jan 22, 2013 (gmt 0)

WebmasterWorld Administrator incredibill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



I concur with <!DOCTYPE html> and HTML 5 as 4.01 is old school, no future in it unless you like building things that are obsolete before they're even finished.
10:28 am on Jan 22, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



I think the question was about "transitional" vs. "strict". Personally I've never seen any reason for "strict". You can make a document that 100% follows the rules for Strict, and call it Transitional. But not the other way around.
1:58 pm on Jan 22, 2013 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



I agree, use the HTML5 DOCTYPE:
<!DOCTYPE html>
It's short, easy to remember, and backwards compatible with HTML 4.01.

If your question is strict vs. transitional HTML 4.01, I'd go with strict. Transitional allows you to use presentational elements/attributes that have been deprecated, which allows for sloppy coding habits that will ultimately only make your job harder. If you're writing strict documents, then use the strict doctype. It's really only used for validation purposes, so using a transitional doctype may give you a false sense that you've written only strict markup.
5:05 am on Jan 23, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



No new web pages have a need for the transitional doctype. The sold purpose of transitional is for web pages being transitioned to strict but still containing old deprecated markup from before 1999! You shouldn't be using old deprecated markup!

The doctype <!DOCTYPE html> puts all browsers into strict standards mode including as far back as IE6. This is the only doctype anyone should use anymore for HTML.
5:21 am on Jan 23, 2013 (gmt 0)

5+ Year Member



Thanks
I think I understand what you are saying, you mean use the Strict one.

But they both start with <!DOCTYPE html>
5:59 am on Jan 23, 2013 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



No, I don't think you do understand. This, in it's entirety, is the HTML5 Doctype:


<!DOCTYPE html>

That's it. No less, no more. That's all you need and all you should be using.
8:26 am on Jan 23, 2013 (gmt 0)

5+ Year Member



I see, thanks
6:37 pm on May 23, 2013 (gmt 0)

10+ Year Member



So literally, this is the start of a new page?

<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My document</title>
7:34 pm on May 23, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Yes. There are a couple of threads elsewhere in the html subforum about the changing definition of "standards". In the past there was HTML2, HTML3, HTML4. In the future there will be HTML and-that's-all.

The dtd shouldn't have a huge effect on the browser's behavior in any case. All of mine are perfectly happy to handle <wbr> in documents marked HTML 4-- so long as I don't try to validate. (The validator doesn't know that you've used an html5 construct. It only knows that it isn't html4. You could have said <xyzzy> for all it cares.)
7:38 pm on May 23, 2013 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



That certainly is a valid HTML5 document, though personally I would still include the <html> tag. Note, the original question was regarding the DOCTYPE, and the <html> tag is not a part of the DOCTYPE. Also, the meta tag can be shortened in HTML5 as well.
Here's the ideal starting point, in my opinion.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>My document</title>
<!-- Put styles in the head, but make sure charset is 1st -->
</head>
<body>
<!-- Put scripts just before closing body tag -->
</body>
</html>
7:48 pm on May 23, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Oops, my bad, I overlooked the missing HTML. That absolutely has to be present, doesn't it?
11:50 pm on May 23, 2013 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Nope. But I wouldn't recommend omitting it.
4:29 pm on May 24, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



<meta charset="utf-8" />

Please note this: The closing slash on that meta tag is XML, superfluous, and ignored in HTML5. In HTML4, it's an error because it's a XML closing tag. It serves no purpose at all unless you are serving the page as application/xml+xhtml and I doubt anyone here is.

Some may find this article illuminating: [tiffanybbrown.com...]

Also this one about omitting tags: [w3.org...]
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month