the best html DOCTYPE

Need help with something HTML related, this is the place to ask.
Post Reply
User avatar
ta2shop
Posts: 179
Joined: Sat May 07, 2011 9:07 am
Location: madrid, Spain
Contact:

the best html DOCTYPE

Post by ta2shop »

just wondering if this is important, if it is what would by the best doctype for html or xhtml websites, or if this is alsow god for .php extensions websites?
Image
User avatar
EcazS
Posts: 789
Joined: Fri May 06, 2011 5:29 pm

Re: the best html DOCTYPE

Post by EcazS »

ta2shop wrote:just wondering if this is important, if it is what would by the best doctype for html or xhtml websites, or if this is alsow god for .php extensions websites?
Doctypes are VERY important and it depends on how you "write", read this http://www.w3schools.com/tags/tag_DOCTYPE.asp

Myself, I always work with XHTML Strict because... it's strict.. :lol:
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: the best html DOCTYPE

Post by jacek »

The doctype you use should tell the browser which elements are used on that page.

The most common one would be xhtml Strict I guess
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title></title>
	</head>
	<body>
		
	</body>
</html>
If you need to use a iframe for anything you need to use a doctype that includes the iframe element, xhtml transitional for example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title></title>
	</head>
	<body>
		
	</body>
</html>
Or if you need to use something from HTML 5 like the canvas tag
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title></title>
	</head>
	<body>
		
	</body>
</html>
so it's not really a question of which is better, you do need one if you want your page to be valid and you should use the right one for the content you have.

Oh and the fact that its a php page makes no difference as you are still outputting html.
Image
User avatar
ta2shop
Posts: 179
Joined: Sat May 07, 2011 9:07 am
Location: madrid, Spain
Contact:

Re: the best html DOCTYPE

Post by ta2shop »

ok, thanks this much more clierer now, i understand i need to use the STRIC one! ;)
thanks guys.
Image
Tino
Posts: 360
Joined: Thu May 05, 2011 8:55 pm
Location: The Netherlands

Re: the best html DOCTYPE

Post by Tino »

By the way, in the HTML5 structure Jacek provided you can just use this for the meta tag instead:
<meta charset="UTF-8" />
Please check out my CodeCanyon items.
User avatar
ta2shop
Posts: 179
Joined: Sat May 07, 2011 9:07 am
Location: madrid, Spain
Contact:

Re: the best html DOCTYPE

Post by ta2shop »

Tino wrote:By the way, in the HTML5 structure Jacek provided you can just use this for the meta tag instead:
<meta charset="UTF-8" />[/xhtml]
actualy hy used:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Image
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: the best html DOCTYPE

Post by jacek »

Tino wrote:By the way, in the HTML5 structure Jacek provided you can just use this for the meta tag instead:
<meta charset="UTF-8" />
Did not know that ! Thanks for the tip ;)
Image
Tino
Posts: 360
Joined: Thu May 05, 2011 8:55 pm
Location: The Netherlands

Re: the best html DOCTYPE

Post by Tino »

ta2shop wrote:
Tino wrote:By the way, in the HTML5 structure Jacek provided you can just use this for the meta tag instead:
<meta charset="UTF-8" />[/xhtml]
actualy hy used:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Yes, that's what he used. But what I did does the same thing but is a lot simpler and is perfectly valid in HTML5 :)

HTML5 is cool like that.
Please check out my CodeCanyon items.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: the best html DOCTYPE

Post by jacek »

I haven't really found any of its things useful yet :?
Image
User avatar
ta2shop
Posts: 179
Joined: Sat May 07, 2011 9:07 am
Location: madrid, Spain
Contact:

Re: the best html DOCTYPE

Post by ta2shop »

thanks guys. ;)
Image
Tino
Posts: 360
Joined: Thu May 05, 2011 8:55 pm
Location: The Netherlands

Re: the best html DOCTYPE

Post by Tino »

jacek wrote:I haven't really found any of its things useful yet :?
Useful, no. But it's still kind of cool in my view :)
Please check out my CodeCanyon items.
sven
Posts: 8
Joined: Tue May 10, 2011 2:29 pm

Re: the best html DOCTYPE

Post by sven »

Very good thread, I've been wondering the same things. Got some answers now. :mrgreen:
nyo
Posts: 124
Joined: Mon May 09, 2011 1:55 pm
Location: Mobile

Re: the best html DOCTYPE

Post by nyo »

Can we say that declaring the DOCTYPE as HTML from now on is safe?

<!doctype html>

I have been using it with my latest websites and no problem so far. I like simplicity and try to optimize the code as much as possible.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: the best html DOCTYPE

Post by jacek »

That would be the HTML5 one...

I think it's fine to use, a lot of the big sites do anyway.

I don’t use it unless I actually need a html5 only tag though.
Image
libeco
Posts: 104
Joined: Sat May 07, 2011 9:56 am

Re: the best html DOCTYPE

Post by libeco »

HTML5 gives me mixed feelings. On one hand it's good to have better semantic tags instead of divs and spans for everything (even though the usage of footer and header for instance is very confusing). On the other hand HTML5 is a huge step backwards because this would be valid:
aTtRiBuTE="vAluE"
I would have liked XHTML2 to be the clear winner, but unfortunately it's back to random and not so strict HTML...
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: the best html DOCTYPE

Post by jacek »

libeco wrote:I would have liked XHTML2 to be the clear winner, but unfortunately it's back to random and not so strict HTML...
That does not mean you can't be string on yourself ;)

Just because you can do stupid things like the one you posted does not really mean you have to.

There may be a XHTML2 after HTML5 ;) I don't think I have been around long enough to understand the difference though.
Image
libeco
Posts: 104
Joined: Sat May 07, 2011 9:56 am

Re: the best html DOCTYPE

Post by libeco »

I can be strict, but allowing for less strict HTML means many (newer) developers will produce sloppier code. Think of the tables of HTML4.

XHTML2 was a proposed standard, following XHTML1.1, but it was rejected because people felt it was too strict. Instead HTML5 (although from version 5 a version number will be omitted) will be the standard for the years to come.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: the best html DOCTYPE

Post by jacek »

So why was XHTML ever used ? :?
Image
libeco
Posts: 104
Joined: Sat May 07, 2011 9:56 am

Re: the best html DOCTYPE

Post by libeco »

To escape from the sloppy and not so strict HTML4 while trying to get a more standardized web.
Tino
Posts: 360
Joined: Thu May 05, 2011 8:55 pm
Location: The Netherlands

Re: the best html DOCTYPE

Post by Tino »

Currently HTML5 gives me mixed feelings as well, but because of a different reason. New developers who will start learning HTML5 probably won't have a clue as to what will and won't work in certain browsers, meaning they'll create partly unusable sites by using features some browsers don't even support!
Please check out my CodeCanyon items.
Post Reply