20

I'm using some HTML5 features on a web page and wondered what the best DOCTYPE is. Currently, this is the DOCTYPE and XMLNS:

<!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">

Should I use the new HTML 5 DOCTYPE?

<!DOCTYPE html>

Will older browsers (IE7, FF 2.x) recognize and render the page correctly? What's the best practice in this situation? Thanks.

Alex
  • 34,699
  • 13
  • 75
  • 158
  • 1
    see http://stackoverflow.com/questions/5629/any-reason-not-to-start-using-the-html-5-doctype – Anurag May 24 '10 at 18:58

1 Answers1

15

Yes, older browsers will work fine. The reason "<!DOCTYPE html>" was chosen in HTML 5 is because it is the smallest a doctype can be and yet still trigger standards compliance mode on those browsers you mention.

ChrisD
  • 3,378
  • 3
  • 35
  • 40
  • 6
    Correct. However, there's one gotcha to be aware of. While the HTML5 doctype will trigger standards compliant mode, assuming the page is being served as text/html, ` ` won't. It'll cause limited-quirks mode instead. See http://dev.w3.org/html5/spec/tokenization.html#the-initial-insertion-mode. If the OP's page relies on this, it'll break with the HTML5 doctype. – Alohci May 24 '10 at 19:32
  • 1
    Another gotcha to be aware of. http://diveintohtml5.org/semantics.html#blank-space-gotcha – Aaron Wagner May 24 '10 at 22:06
  • @Alohci - links break over time, so I suppose 3 years later the link its now http://www.w3schools.com/tags/tag_doctype.asp – Wilf Jan 16 '14 at 22:37