Page 1 of 1
the best html DOCTYPE
Posted: Mon May 09, 2011 11:01 am
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?
Re: the best html DOCTYPE
Posted: Mon May 09, 2011 11:11 am
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.aspMyself, I always work with XHTML Strict because... it's strict..
![Laughing :lol:](./images/smilies/icon_lol.gif)
Re: the best html DOCTYPE
Posted: Mon May 09, 2011 11:15 am
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
[syntax=xhtml]<!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>[/syntax]
If you need to use a iframe for anything you need to use a doctype that includes the iframe element, xhtml transitional for example
[syntax=xhtml]<!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>[/syntax]
Or if you need to use something from HTML 5 like the canvas tag
[syntax=xhtml]<!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>[/syntax]
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.
Re: the best html DOCTYPE
Posted: Mon May 09, 2011 11:19 am
by ta2shop
ok, thanks this much more clierer now, i understand i need to use the STRIC one!
thanks guys.
Re: the best html DOCTYPE
Posted: Mon May 09, 2011 11:27 am
by Tino
By the way, in the HTML5 structure Jacek provided you can just use this for the meta tag instead:
[syntax=xhtml]<meta charset="UTF-8" />[/syntax]
Re: the best html DOCTYPE
Posted: Mon May 09, 2011 11:40 am
by ta2shop
Tino wrote:By the way, in the HTML5 structure Jacek provided you can just use this for the meta tag instead:
[syntax=xhtml]<meta charset="UTF-8" />[/xhtml]
actualy hy used:
[syntax=xhtml]<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
[/syntax]
Re: the best html DOCTYPE
Posted: Mon May 09, 2011 11:41 am
by jacek
Tino wrote:By the way, in the HTML5 structure Jacek provided you can just use this for the meta tag instead:
[syntax=xhtml]<meta charset="UTF-8" />[/syntax]
Did not know that ! Thanks for the tip
![Wink ;)](./images/smilies/icon_e_wink.gif)
Re: the best html DOCTYPE
Posted: Mon May 09, 2011 11:43 am
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:
[syntax=xhtml]<meta charset="UTF-8" />[/xhtml]
actualy hy used:
[syntax=xhtml]<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
[/syntax]
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
![Smile :)](./images/smilies/icon_e_smile.gif)
HTML5 is cool like that.
Re: the best html DOCTYPE
Posted: Mon May 09, 2011 11:49 am
by jacek
I haven't really found any of its things useful yet
![Confused :?](./images/smilies/icon_e_confused.gif)
Re: the best html DOCTYPE
Posted: Mon May 09, 2011 11:51 am
by ta2shop
thanks guys.
![Wink ;)](./images/smilies/icon_e_wink.gif)
Re: the best html DOCTYPE
Posted: Mon May 09, 2011 12:29 pm
by Tino
jacek wrote:I haven't really found any of its things useful yet
![Confused :?](./images/smilies/icon_e_confused.gif)
Useful, no. But it's still kind of cool in my view
![Smile :)](./images/smilies/icon_e_smile.gif)
Re: the best html DOCTYPE
Posted: Tue May 10, 2011 2:40 pm
by sven
Very good thread, I've been wondering the same things. Got some answers now.
![Mr. Green :mrgreen:](./images/smilies/icon_mrgreen.gif)
Re: the best html DOCTYPE
Posted: Sun May 15, 2011 4:59 pm
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.
Re: the best html DOCTYPE
Posted: Sun May 15, 2011 5:07 pm
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.
Re: the best html DOCTYPE
Posted: Sun May 15, 2011 6:32 pm
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:
[syntax=xhtml]aTtRiBuTE="vAluE"[/syntax]
I would have liked XHTML2 to be the clear winner, but unfortunately it's back to random and not so strict HTML...
Re: the best html DOCTYPE
Posted: Sun May 15, 2011 6:48 pm
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
![Wink ;)](./images/smilies/icon_e_wink.gif)
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
![Wink ;)](./images/smilies/icon_e_wink.gif)
I don't think I have been around long enough to understand the difference though.
Re: the best html DOCTYPE
Posted: Sun May 15, 2011 7:13 pm
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.
Re: the best html DOCTYPE
Posted: Sun May 15, 2011 7:20 pm
by jacek
So why was XHTML ever used ?
![Confused :?](./images/smilies/icon_e_confused.gif)
Re: the best html DOCTYPE
Posted: Sun May 15, 2011 7:27 pm
by libeco
To escape from the sloppy and not so strict HTML4 while trying to get a more standardized web.
Re: the best html DOCTYPE
Posted: Sun May 15, 2011 8:56 pm
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!