Welcome to WebmasterWorld Guest from 54.146.201.80

Forum Moderators: incrediBILL

Message Too Old, No Replies

Question about what !DOCTYPE and HTML tags should look like?

     
6:27 pm on Nov 12, 2012 (gmt 0)

Full Member

5+ Year Member

joined:June 30, 2008
posts: 318
votes: 0


hi all,

the site that I'm developing uses javascript, jQuery, Ajax calls to php and standard html tags. I want the site to be future proof.

So my question is...

What should the !DOCTYPE and HTML tags look like now?

I'm currently using the following:
<!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' xml:lang='en' lang='en'>

<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<meta http-equiv='X-UA-Compatible' content='IE=edge' />


From what i've been reading about HTML5, it appears i should be using the following:
<!DOCTYPE html>

<html lang='en'>

<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<meta http-equiv='X-UA-Compatible' content='IE=edge' />


But i also want to make sure the html documents are marked up correctly and "well-formed" which is what the XHTML attribute is for.

So how should it be constructed to handle HTML5 and still be marked up correctly?
10:02 pm on Nov 12, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 23, 2005
posts:742
votes: 0


To serve web pages on the web, the only thing you should need is this:

<!DOCTYPE html>

What you have in the head is most likely unnecessary. The charset should be set in the server and that is only necessary if the page is being saved on the desktop. The second is only to make sure IE stays in its current IE standards mode but that's what the doctype is for. Good browsers, anything but IE, never had a need for it with HTML.

The doctype is one that puts browsers into standards mode and has nothing to do with HTML5 actually.

Side note: Doctypes only exist for IE's sake. IE is the only browser that needs one because, years ago, it started the "quirks mode" problem that other browsers had to become compatible with. The only way to get out of quirks mode was to tell the browser it was following the document type published by the W3C, hence the longer doctypes of days gone by.

Fortunately, browsers today don't actually go to the URL to fetch the doctype so all that was eliminated.
10:21 pm on Nov 12, 2012 (gmt 0)

Full Member

5+ Year Member

joined:June 30, 2008
posts: 318
votes: 0


great thanks. I've changed it to:
<!DOCTYPE html>

<html lang='en'>

<head>

and everything still works.

Is the lang attribute in the html tag required if the web app is only used in the USA?
11:42 pm on Nov 12, 2012 (gmt 0)

Administrator

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

joined:Aug 10, 2004
posts:10542
votes: 8


I want the site to be future proof.

i would include the lang attribute in the html tag.
12:39 am on Nov 13, 2012 (gmt 0)

Full Member

5+ Year Member

joined:June 30, 2008
posts: 318
votes: 0


thanks.
10:22 am on Nov 13, 2012 (gmt 0)

Senior Member

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

joined:Aug 7, 2003
posts:4783
votes: 0


If you come from xhtml, the most logical approach is to go to polyglot (x)html5.
See here: [webmasterworld.com...]
3:17 am on Nov 17, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 23, 2005
posts:742
votes: 0


The lang attribute is only there so things like screenreaders know the language of the document is English so it can get the pronunciation right. The html element itself is only optional.