Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 26th, 2005, 9:51 AM   #1
TerraNerd
Programmer
 
TerraNerd's Avatar
 
Join Date: Jul 2004
Location: Vermont, USA
Posts: 65
Rep Power: 5 TerraNerd is on a distinguished road
Send a message via AIM to TerraNerd
!DOCTYPE - What does this mean?

In my book on PHP, it allways starts a section of code, as if it were starting the page of code, with the fallowing:

<!DOCTYPE html PUBLIC
     "=//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

and it never expains what that means, yet it's in each example of code.



im going to guess DOCTYPE is the type of the document, but yet with the ! operator, which is 'not,' right? So im guessing it's saying 'not an html public document.' However im lost after that.
__________________
[See a gallery of my Graphic art Here.][Visit my website Here]
TerraNerd is offline   Reply With Quote
Old Feb 26th, 2005, 10:57 AM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
The ! just means "I'm a special type of tag! Look at me!" in this case. It isn't C - different language here.

And as always, Google is your friend.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Feb 26th, 2005, 11:57 AM   #3
TerraNerd
Programmer
 
TerraNerd's Avatar
 
Join Date: Jul 2004
Location: Vermont, USA
Posts: 65
Rep Power: 5 TerraNerd is on a distinguished road
Send a message via AIM to TerraNerd
i also want to know what the whole thing means as well, not just the !
__________________
[See a gallery of my Graphic art Here.][Visit my website Here]
TerraNerd is offline   Reply With Quote
Old Feb 26th, 2005, 12:07 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Then click the link...
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Feb 26th, 2005, 4:12 PM   #5
Lance
Programmer
 
Lance's Avatar
 
Join Date: Oct 2004
Location: Chicago, IL USA
Posts: 74
Rep Power: 4 Lance is on a distinguished road
Send a message via AIM to Lance
The "DOCTYPE" tag is the "DOCument TYPE" you want the webpage to be rendered in.

Purposes include: Helping you validate your site at http://validator.w3.org

And to change the "mode" of your browser: Firefox, and I assume quite a few other browsers, have two modes:
  1. Standards Compliant Mode
  2. Quirk Mode

If you choose to use mode 1, Standards Compliance Mode, you need to specify the Document Type you are complying to. That is, if you code a proper website, you are using a Standard Compliance Mode. This causes Firefox to render the site according to the specification of that language, and won't render glitches (referred to as (rendering) "quirks" in the browsers).

Now, if you use mode 2, Quirks Mode, you are telling the browser to allow glitches/hacks to be used to render a site the way IE would render it. Or at least, close to it.

Example of a quirk:

Back in the day, there were websites, that upon loading, would fade from black to white, then display the website content. This was a quirk found in the Netscape browser of old, and many personal websites (and even some professional) would use it to add "style" to their site. How was this accomplished? Take a look at this code below:

[php]<html>

<head>
<title>My Website</title>
</head>

<body bgcolor="#000000"></body>
<body bgcolor="#111111"></body>
<body bgcolor="#222222"></body>
<body bgcolor="#333333"></body>
<body bgcolor="#444444"></body>
<body bgcolor="#555555"></body>
<body bgcolor="#666666"></body>
<body bgcolor="#777777"></body>
<body bgcolor="#888888"></body>
<body bgcolor="#999999"></body>
<body bgcolor="#AAAAAA"></body>
<body bgcolor="#BBBBBB"></body>
<body bgcolor="#CCCCCC"></body>
<body bgcolor="#DDDDDD"></body>
<body bgcolor="#EEEEEE"></body>
<body bgcolor="#FFFFFF">


<h2>My Website</h2>

<p>Check out my cool website! The background fades from black to white!</p>

</body>

</html>[/php]

I used the PHP vB code in order to get the HTML colored right. So disregard the "PHP Code:" thing.

Anyways, what Netscape would do in that instant, is read the page from top to bottom. It would see a body tag that had a background color of black, and so it would render that, but then the body would close, and another color would have to be rendered. Cool, huh?

Either way, that "quirk" has long been dead. And I bet Firefox's quirk mode won't support it either. I just needed to show an example of what a quirk is, in order for you to see what I mean. Now, the proper way to code, is, of course, to use Standard Compliance Mode, to comply with the World Wide Web Consortiums documentation on how HTML should be rendered and written.

So, all in all--this was an exhaustive post to help you gain a little insight as to why DOCTYPE exists and what it's mainly used for.

Did you catch any of that? :p
__________________
/* LANCE */
C++;  /* this makes C bigger but returns the old value */
char *site = "slackwise.net",
     *home = "lance.slackwise.net",
     *pics = "flickr.com/photos/slackwise";
Lance is offline   Reply With Quote
Old Feb 26th, 2005, 4:16 PM   #6
TerraNerd
Programmer
 
TerraNerd's Avatar
 
Join Date: Jul 2004
Location: Vermont, USA
Posts: 65
Rep Power: 5 TerraNerd is on a distinguished road
Send a message via AIM to TerraNerd
read it all twice, thanks!
__________________
[See a gallery of my Graphic art Here.][Visit my website Here]
TerraNerd is offline   Reply With Quote
Old Feb 26th, 2005, 4:54 PM   #7
Lance
Programmer
 
Lance's Avatar
 
Join Date: Oct 2004
Location: Chicago, IL USA
Posts: 74
Rep Power: 4 Lance is on a distinguished road
Send a message via AIM to Lance
Oh, and I guess I forgot to mention that if you specify a DOCTYPE, you are saying that website needs to be rendered for that type using Standards Compliance Mode, but if you don't specify a DOCTYPE, it assumes Quirks Mode.

But I guess that was implied. :p

Now, for something cooler: The Firefox Web Developer Extension

This is an extension to the Firefox browsers, which provides you with a toolbar that lets you do tons of things to the websites you work on, in order to help you designer faster and cleaner.

Here is a quick list of features it provides you with, all at your fingertips.
  • Disable JavaScript
  • Draw borders around block-level objects
  • Validate HTML
  • Validate CSS
  • Turn off images
  • Turn off styles
  • See what mode the site is being rendered in

And a whole lot more! Now the cool thing is, on the right side of the toolbar, you will see a blue circle with a check mark inside it. If it's faded, the site is being rendered in "Quirks Mode". If you click the check mark/cirle, it will even say so, along with some other information about it. And if the check mark/circle is nice and blue (i.e. not faded) then it's in Standards Compliance Mode.

Pretty nifty, isn't it? And if you're not using Firefox... then you better get started NOW!

Also, there is an an IE View extension, which allows you to quickly open the site your viewing in IE. This helps when you're designing a XHTML/CSS site, and you need to check if IE is rendering things like Firefox, or if you'll need to modify your markup (or add PHP code) to compensate for rendering issues.

Anyways, hope that was of help to you, and any others that read this thread.
__________________
/* LANCE */
C++;  /* this makes C bigger but returns the old value */
char *site = "slackwise.net",
     *home = "lance.slackwise.net",
     *pics = "flickr.com/photos/slackwise";
Lance is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:42 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC