-1

When starting an html document I always write

<!doctype html>
<html>

But there are lots of sites writing it as

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

Is there a danger in doing it the way I do ? Whats the benefit of all the extra attributes?

sam
  • 9,486
  • 36
  • 109
  • 160

4 Answers4

0

You're using the HTML5 doctype, see http://ejohn.org/blog/html5-doctype/ and http://alistapart.com/article/doctype/

devdigital
  • 34,151
  • 9
  • 98
  • 120
0

What you're setting your doctype to is HTML5. The other versions you've seen are for the lower (HTML4.01, etc) versions.

As far as I am aware, using the HTML 5 tag should cause too many problems unless people are viewing your site on older (IE6 or lower) browsers.

You can find a more comprehensive guide here: http://www.w3schools.com/tags/tag_doctype.asp

evilscary
  • 2,097
  • 5
  • 23
  • 33
0

those sites are using before html5 version.But you are using html5 version.In html5 you can simply specify the doctype like

<!doctype html>

But in previous versions(before html5) we have doctype like

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
PSR
  • 39,804
  • 41
  • 111
  • 151
0

Usually a <!DOCTYPE> declaration is used to distinguish between versions of HTMLish lanaguages (in this case, HTML or XHTML).

Different markup languages will behave differently. For example is height:100%

NOTE:(This is important): Do not mix HTML with XHTML

You'll notice that the height of the components is drastically different, and the only difference between the documents!!!!

Vitthal
  • 546
  • 3
  • 18