How improtant is the doctype tag?
I am trying to teach myself html and am trying to figure out when to use what doctype.
DOCTYPE basically tell the web browser what to expect when interpreting the html doc b/c html has been revised over the years, is that correct?
Can someone please help me understand how to properly use the doctype tag and what is smart choice/ example of a specific doctype tag is and the reasoning behind why 'this' doctype tag is a smarter choice than an alternate doctype tag?
Thank you!
DOCTYPE Tag?
Started by
_*Ogflsnnbs_*
, Aug 24 2011 04:27 AM
2 replies to this topic
#1 _*Ogflsnnbs_*
Posted 24 August 2011 - 04:27 AM
#2
Posted 19 December 2011 - 07:42 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Typically this will work best for most browsers - often if I am having issues with cross-browser compatibility when using floated elements and relative positioning between Firefox and IE, it's because I forgot to add this declaration.
I don't understand the technicalities of it, what I do understand is hours of grinding away getting a site to look the same in IE8 and Firefox
#3
Posted 30 March 2012 - 10:41 PM
Basically it is just a small piece that tells the browser how to expect to parse the document. It determines whether your document should be parse as HTML strict versus standard, what version to use, and where it can get more information. That is what the DTD part is, where it points to the W3 site. The one that JimmyJames posted is pretty much the standard HTML 4 Strict one that most sites use. I personally use XHTML Strict with this snippet:
The nice thing is that the HTML5 one is simpler since it has no reliance on a DTD, which means no more having to copy/paste a big ugly doctype header into future websites we will be making.
Done!
As mentioned, if you omit the doctype you can get wierd bugs, especially in IE. I've had some crazy stuff happen only to find IE was in quirks mode... adding the doctype I had forgotten fixed it all.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
The nice thing is that the HTML5 one is simpler since it has no reliance on a DTD, which means no more having to copy/paste a big ugly doctype header into future websites we will be making.
<!DOCTYPE html>
Done!
As mentioned, if you omit the doctype you can get wierd bugs, especially in IE. I've had some crazy stuff happen only to find IE was in quirks mode... adding the doctype I had forgotten fixed it all.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users