< Browse > Home / Class Notes, XHTML & Coding / Blog article: DocType and Your Lessons

| Mobile | RSS

DocType and Your Lessons

June 27th, 2005 | 1 Comment | Posted in Class Notes, XHTML & Coding

When creating valid XHTML documents you must specify the DTD or Document Type Definition at the beginning of your document. This DTD is also called a Doctype. The Doctype code tells the browser how to interpret the remainder of the code on the page. There are three Doctypes that you can use when working with XHTML. They are strict, transitional and frameset. Doctype statements should be placed at the beginning of the XHTML document before any other code. These Doctype statements were created by the W3C and they specify the language being used in the XHTML document. In essence they tell the browser how it should behave when it displays the web page.

There is a major flaw in the XHTML book that we are using in class. It does not introduce the DocType statement until tutorial 9. Some students have decided to start utilizing the XHTML DocType statement in each of their documents, but they have discovered that their documents no longer render properly in Internet Explorer (positioning errors may occur).

Why do these errors occur? Well, the author who coded the XHTML documents did not include the unit of measurement when declaring positioning values. For example:

[code]

#linklist {
position: absolute; top: 110; left: 5;
}
[/code]

If you use a doctype statement with this CSS the linklist will not be positioned properly on the page. In order to correct the positioning issue you must declare the unit of measurement like this:

[code]

#linklist {
position: absolute; top: 110px; left:5px;
}
[/code]

In valid XHTML any value over 0 must include the unit of measurement. In the above example we are working with pixels, so the px must be added to the value 110px.

While you are not required to create valid XHTML transitional documents until tutorial 9, you may want to get in the practice of using DocType statements now. The tutorial 1 section of your XHTML assignment sheet shows an example of the transitional XHTML DocType.

If you would like to read more about DocType, you can read ahead to tutorial 9 (pg. 483) of your XHTML book or take a look at this basic XHTML tutorial.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • StumbleUpon
  • Design Float
  • Reddit
  • Twitter
Leave a Reply 640 views, 2 so far today |
Follow Discussion

One Response to “DocType and Your Lessons”

  1. David Hucklesby Says:

    Holly Bergevin wrote an article on Rendering Mode and Doctype Switching for Community MX. It explains what it is and what it does, with a list of all of them for you to copy and paste.

    Cordially, David

BubbleRelaxPlasmaBubbleDripPlaying with Water and LightPlaying with Water and LightPlaying with Water and LightPlaying with Water and LightPlaying with Water and LightwetJust Posing