Welcome to WebmasterWorld Guest from 54.160.131.144

Forum Moderators: incrediBILL

Message Too Old, No Replies

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

     

nelsonm

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

5+ Year Member



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?

drhowarddrfine

10:02 pm on Nov 12, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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.

nelsonm

10:21 pm on Nov 12, 2012 (gmt 0)

5+ Year Member



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?

phranque

11:42 pm on Nov 12, 2012 (gmt 0)

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



I want the site to be future proof.

i would include the lang attribute in the html tag.

nelsonm

12:39 am on Nov 13, 2012 (gmt 0)

5+ Year Member



thanks.

swa66

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

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



If you come from xhtml, the most logical approach is to go to polyglot (x)html5.
See here: [webmasterworld.com...]

drhowarddrfine

3:17 am on Nov 17, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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.