homepage Welcome to WebmasterWorld Guest from 54.145.182.50
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

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

5+ Year Member



 
Msg#: 4518382 posted 6:27 pm on Nov 12, 2012 (gmt 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?

 

drhowarddrfine

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4518382 posted 10:02 pm on Nov 12, 2012 (gmt 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.

nelsonm

5+ Year Member



 
Msg#: 4518382 posted 10:21 pm on Nov 12, 2012 (gmt 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?

phranque

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



 
Msg#: 4518382 posted 11:42 pm on Nov 12, 2012 (gmt 0)

I want the site to be future proof.

i would include the lang attribute in the html tag.

nelsonm

5+ Year Member



 
Msg#: 4518382 posted 12:39 am on Nov 13, 2012 (gmt 0)

thanks.

swa66

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



 
Msg#: 4518382 posted 10:22 am on Nov 13, 2012 (gmt 0)

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

drhowarddrfine

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4518382 posted 3:17 am on Nov 17, 2012 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved