Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Document Type Declarations, And why we use them in html pages
jlhaslip
post Nov 19 2006, 02:07 AM
Post #1


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,866
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



This code:
CODE

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <title>HTML 4.0 Strict document</title>
    <meta http-equiv="content-type"  content="text/html;charset=utf-8" >
    <meta http-equiv="Content-Style-Type"  content="text/css" >
</head>

<body>

     <p>... Your HTML content here ...</p>
     <p>... More HTML content here ...</p>
  </body>
</html>

represents a minimum, acceptable web-page according to the W3C which is the organisation that sets the standards for the World Wide Web, or as we call it, the Internet.
In another Tutorial, you can learn about the html code, but in this Tutorial, I wish to emphasis the importance of the DTD or Document Type Declaration, the first line in the sample code above.

What it does is tells the Browser that a certain set of rules are to be applied to this page when the Browser renders the document. In this case, the author expects the Browser to use the rules as defined by the W3C for their Html 4.0 Strict documents and the rules are available at the link described in the DTD. (http://www.w3.org/TR/html4/strict.dtd). This ruleset is public as declared in the DTD.

The importance of using a DTD is that 'most' Browsers will display the document in a specific manner, according to the rules as defined by the DTD in use. Of course, there are exceptions and we all know the Browser by name , but let's not get into Browser wars here.

Without using a DTD, or using an incorrect one for the code you insert in the page, the Browser will be forced to interpret the code in a manner it deems appropriate, regardless of the known standards, so there will be a larger variation in the Browser rendering of the page in 'Quirks' mode. Without the DTD, each Browser uses its own set of rules and the output can be different in each Browser, so if you are experienceinfg difficulties with cross-browser rendering, also ensure the DTD used in a page is a correct, valid one for the code you have used on the page. The DTD used above is html4.0 Strict. If you intend on using it, ensure your code does not include elements which are invalid for that standard, or expect the Browser to display your page in Quirks Mode, and unpredictable results may occur.

There are, of course, other DTD's and a good source of them is at the W3C site.

Any questions, post here and I will do my best to answer them.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. where did you learn html from?(84)
  2. Flash Media Into Html/css Website(1)
  3. Does Anyone Know Where I Can Get A Free Html Maker(13)
  4. Add Flashing Inbox To Invisionfree Forum(0)
  5. Bloobs(5)
  6. How Fast Can You Type The Alphabet?(63)
  7. Adding Rows & Columns In Html Table Using Javascript(1)
  8. Has Anybody Tried Ms Expression Web Html Editor(3)
  9. Html Form!(4)
  10. Html Code Tester. Online Script(15)
  11. Learn Html, Css, C And C++ Online For Free(12)
  12. Where Is There A Good Site To Learn Web Html?(18)
  13. Help! Php Or Just Html?(13)
  14. Simple Javascript And Password System(6)
  15. What Is The Best Free Html Editor?(8)
  1. Html Countdown For Your Wallpaper For Your Computer?(5)
  2. Test Your Php Pages W/o Upload/internet(57)
  3. Canadian Dcma-type Bill Introduced(1)
  4. Html Problem(9)
  5. Mime Type Trouble(3)
  6. How To: Make A Simple Php Site(21)
  7. Rpg Maker 2003(7)
  8. Problem With Firefox, Latest Version, Not Loading Pages(4)
  9. A Twist On Basic Authentification(1)
  10. The Best And Free Website/html Editors + Text Editors(46)
  11. Html Page Not Showing Up In Firefox(1)
  12. Best Html Webdesign Studio(2)
  13. Html In Os X- Linking To An Alias(0)
  14. Help Making A Web Adress Bar Using Html/js(9)
  15. Fave Type Of Music?(26)


 



- Lo-Fi Version Time is now: 20th July 2008 - 11:50 AM