First line of HTML code <!DOCTYPE HTML PUBLIC .

  • User #2
  • Student
  • Student
  • User #2
  • Posts: 89

Post 3+ Months Ago

What does that code do?
this one below.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

Do I need it?
What happends if I don't use this code?
Can I miss-use?
Is it important?

Thank you.
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23469
  • Loc: Woodbridge VA

Post 3+ Months Ago

Your document will work without it. You could do

Code: [ Select ]
<title>My Web Page</title>
Hello World
  1. <html>
  2. <head>
  3. <title>My Web Page</title>
  4. </head>
  5. <body>
  6. Hello World
  7. </body>
  8. </html>

and the page will display just fine in most browsers, but it's not correct.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
is what's know as a "document type declaration (or definition)" (DTD). In essence it identifies to the browser the type of code that is being used in the document. When declaring a doctype, it is then your responsibility as a designer to code the page to the specifications you have "declared" you are using in the doctype. In your example, you are declaring to the browser that you will be writing your code to HTML 4.01 transitional specifications and that is what it is expecting. If you falter from those "expectations" then your code may become considerd as "invalid" and may not display correctly in some browsers.

This is where things start to get a little confusing. The transitional doctype was institituted to allow a transitional period for designers to migrate from older coding standards to newer coding standards. An alternative to a "transitional" doctype would be a "strict" doctype.

In the example you have provided the distinction would be that for a "strict" doctype to be valid and display correctly, then you must write the code for your pages specifically to HTML 4.01 standards, whereas using a "transitional "doctype would allow you to use depracated (i.e. obsolete) code from say perhaps, HTML 4.0 or HTML 3.2 and, although it's planned to eventually be elliminated would at least still work for the time being.

An example would be <font> tags. Very old coding practice and now depricated and has been replaced by using style instead.

For more on doctype declarations (a.k.a. DTD's) go here

(one of these days I need to do a complete tutorial on this.)

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 28 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.