...

View Full Version : Correct Doctype for HTML5 - or as near as possible.



effpeetee
09-02-2010, 03:07 PM
I have been playing aroung with html5 and css3 for a while, but I still do not understand what Doctype and header to use for the pages.:confused:

A helpful explanation would be greatly appreciated.
Frank - the headless wonder!:D

Lerura
09-02-2010, 04:09 PM
http://www.w3schools.com/html5/tag_doctype.asp

oracleguy
09-02-2010, 05:31 PM
This isn't a general PC issue. Moving the HTML forum.

effpeetee
09-02-2010, 06:46 PM
Yes. But I meant the whole of the heading from the top to the<head>
Language and utf.

I have a working header on my home page but I would like to be sure that it is complete. I have no real knowledge of this. I have always just c and p'ed from somebody elses site.

Frank

Dormilich
09-02-2010, 08:06 PM
HTML5: <!DOCTYPE HTML>

XHTML5:
- important: no DTD (the XML parser would try to validate the page, but will fail due to the incomplete DTD)
- XML prolog if you’re not using UTF encoding
- important: send an "application/xhtml+xml" Content-Type header from the server (or use the .xhtml extension)

Apostropartheid
09-02-2010, 08:10 PM
The elements in the head of the document haven't really changed, Frank (: the only difference I can think of is that there's a different way you can declare your character encoding:


<head>
<title></title>
<meta charset="utf-8">
</head>

Dormilich
09-02-2010, 08:15 PM
bear in mind that server settings overwrite page settings, so if you set a Content-Encoding header on the server, the content encoding in your <meta> tag gets ignored (there are some headers automaticly set by the server, e.g. the Content-Type header). nevertheless it’s good practice to always include the headers in the page as well.

effpeetee
09-03-2010, 09:37 AM
Thank you all. This is what I am using now.


<!DOCTYPE html>
<html lang="en">
<head>
<title>Web coders resource. Uses javascript,HTML5 and CSS3</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
</head>

Frank

Lerura
09-03-2010, 01:27 PM
It is a valid and complete HTML5 <head> except 2 small things:

lang="en"is not HTML5

and (according to the references) The <meta> goes before the <title>
------------
And you can shorten it a bit

in
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
the red parts is optional.

so

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8">
<title>Web coders resource. Uses javascript,HTML5 and CSS3</title>
</head>
is the best

Dormilich
09-03-2010, 01:52 PM
It is a valid and complete HTML5 <head> except 2 small things:

lang="en"
is not HTML5

wrong (http://dev.w3.org/html5/spec/Overview.html#the-lang-and-xml:lang-attributes)



<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Web coders resource. Uses javascript,HTML5 and CSS3</title>
</head>
is the best

at least fix your typos!

Major Payne
09-03-2010, 04:34 PM
This is standard for HTML 5 in my web editor:


<!DOCTYPE html>
<html lang="en"><head>
<meta charset="utf-8">
<meta name="created" content="Fri, 03 Sep 2010 14:32:26 GMT">
<meta name="description" content="">
<meta name="keywords" content="">
<title></title>

<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>

</body></html>


Add anything else you think you need. The script reference is currently needed.

effpeetee
09-03-2010, 08:55 PM
This is standard for HTML 5 in my web editor:


<!DOCTYPE html>
<html lang="en"><head>
<meta charset="utf-8">
<meta name="created" content="Fri, 03 Sep 2010 14:32:26 GMT">
<meta name="description" content="">
<meta name="keywords" content="">
<title></title>

<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>

</body></html>


Add anything else you think you need. The script reference is currently needed.
Thank you Major Payne.
Works fine.

Incidentally, what is you web editor?

Frank

Major Payne
09-03-2010, 09:04 PM
Incidentally, what is you web editor?

FrankI have several free and paid ones. The current one I am using is CoffeeCup's HTML Editor 2010 SE which generates the HTML 5 file if I choose that doctype.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum