PDA

View Full Version : What is this....?


CSUjr
03-18-2006, 02:36 AM
I am new to web design and I'm working on my first web site using Dreamweaver 8.

I have made a few pages and then looked at the code.

There is code above the <head> that I don't understand.

Can anyone tell me what it is, why it is there, who is www.w3.org and is this really necessary to be part of the page?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

My first guess was that it is used to set the language to English. If so, is there another way to set the language without having to have this refer to a web site to do it?

If that's not what it is then - What is this...?

Creative Insanity
03-18-2006, 02:56 AM
Yes it does need to be there as that is the doc type (although you are using the wrong one) as it tells the browser how to render the pages. If it is not there then the page can be rendered anyway the browsers sees fit.. which is bad.
The correct doc type you need is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

CSUjr
03-18-2006, 03:27 AM
I thought that it had to be in the code but your answer still leaves questions.

First, you said that the code that I posted is wrong. While I'm not saying that it is not, why then (being wrong) did Dreamweaver put it in there that way?, if you know.

Can you tell me, if you know why the reference to the w3.org web site is there? In other words - is that the Only way to render pages to the browser?, if you know

Thanks

gmcrone
03-18-2006, 06:43 AM
Doc Types are standards set by the W3C to tell the browser which standard of display to use in presenting your pages.
And yes they are necessary.
You are using an XHTML standard which is the newer version for more modern browsers. It is much more strict in its interpretation of how your web pages are written.

DW put this code in because in your preferences you have set it up to use this doc type. This can be changed in preferences, new document, default document type.

You are not necessarily using the wrong Doc type, its just that CI is set in his ways and doesn't want to use anything new.. :)

Mike...

Creative Insanity
03-18-2006, 08:47 AM
LOL @ gm.. anything new indeed.. LOL.. what is new?

gmcrone
03-18-2006, 09:15 AM
XHTML 1.1 is the "new"
This is the latest approved recommendation from the W3C.

As if you didn't know :)

Mike...

ramandeep
03-18-2006, 10:23 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

This DOCTYPE is not wrong , what matters is how you serve it. When dreamweaver adds this DOCTYPE it is also serving it as text/html
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
so this is HTML compatible XHTML 1.0 if sent with the “text/html” mime type.

XHTML 1.1 has to be served as type application/xhtml+xml and forget serving pages to IE using XHTML 1.1 as IE doesn't accept pages served as that :? .
We can use detection script to serve up a different mime type depending on browser but unless you need the extensible nature of XHTML there’s no real reason to using it.

CSUjr
03-18-2006, 02:05 PM
Thank you, I found some of the answers to my questions very lucid and helpful.

As I mention previously, I am working in Dreamweaver 8 so the following questions are in regard to that specific program.

When I view my Code I see that it is made up of Bold and Regular characters in a variety of colors.

It seems somewhat obvious that the words that are at the beginning of each statement, which are in Black, are indicators of types of things, such as specific functions, etc. But why are some of those in Bold and some of them in regular font? i.e., what does that indicate, or what does that mean?

The rest of the Code is made up of a variety of colors which are Blue, Red, a dim shade of Red and Green.

Blue is the most predominate color and, as with the Black, is in Bold and regular font. What does the color Bold Blue indicate and what does the regular font Blue indicate? What does the Red indicate? What does the dim shade of Red indicate and what does the Green indicate?

In specific regard to Dreamweaver 8, I realize that these questions might not be readily answerable by some that are not very familiar and adept with Dreamweaver 8, but for those that are, I would like to know, if you can tell me.

Thanks again

ramandeep
03-18-2006, 05:25 PM
When you view the code in the code view you see variety of color as there are the different colors given to different properties, like for example in HTML
there are different colors for form, image, anchor, attribute, style , table etc.
You can specify or edit them by going to
Edit- Preferences-Code coloring and then editing the coloring scheme.

This makes hand coding much easier !

http://www.macromedia.com/support/dreamweaver/extend/extensible_code_coloring/
This is a extensible code coloring document from macromedia which you might find helpfull if you wish extend the Dreamweaver MX code coloring schemes .

domedia
03-19-2006, 05:29 PM
XHTML 1.1 has to be served as type application/xhtml+xml and forget serving pages to IE using XHTML 1.1 as IE doesn't accept pages served as that :? .
Which actually leaves the question: Is it right for us to use this doctype then? If IE is not going to serve the page as XML but text/html, why not stick with 4.01 strict?

but unless you need the extensible nature of XHTML there’s no real reason to using it. Right On :)

ramandeep
03-19-2006, 07:14 PM
Dom,
As far as browsers are concerned,doctype declaration doesn't matter at all.
The doctype is only used when you're validating your document. so that it can know which flavour of XHTML we are using.

For IE
application/xhtml+xml MIME type is not supported but we can serve it as application/xml, which it supports and treat as XML.

d a v e
03-19-2006, 08:11 PM
"As far as browsers are concerned,doctype declaration doesn't matter at all. " (ramandeep) er except if you miss it out or use an incomplete one IE for example will go into quirks mode and that's going to make a noticable difference to your layout when the box model comes into play

domedia
03-20-2006, 12:36 AM
Dom,
As far as browsers are concerned,doctype declaration doesn't matter at all.

You'll see webpages rendered differently based on doctype because it decides if it throws the browser into quirksmode or not. So depending on how you see it, doctype has a definitive matter of how a page looks.

Creative Insanity
03-20-2006, 02:00 AM
I agree with dom 100% and I know this from past experience.
I never use to use doc types and sites looked differant in all browsers.
Opera rendered the page one way, IE another, Netscape another and so on.
But having a doc type is like having good parents for your pages and that will TELL the browser how to display and if you are naughty w3.com will come down on you like a ton of bricks.
Now that I do use a doc type I hardly ever test on more than one browser as I know that it will display more times than not in all as good old Doc is on the case.
A good habit to get into in my books. So Dave.. it DOES matter.

d a v e
03-20-2006, 04:18 AM
"So Dave.. it DOES matter."

er that's what i said, creative ;)

i would also recommmend always testing on more than one browser anyway even with a doctype!

ramandeep
03-20-2006, 09:17 AM
What I was trying to say was that the doctype declaration doesn't affect how a browser parses and interprets the document. An XHTML doctype doesn't make a browser use the XML parser, nor does it make the browser apply XML rules to the document. It's the combination of the Content-Type HTTP header and the XML namespace declaration that tells a browser that the document is XHTML.

The doctype declaration does matter for modern browsers, though, due to the concept of doctype switching which was introduced in IE5/Mac IIRC.
Doctype switching only affects how the document is rendered, though. It affects how CSS rules are applied, but not how the markup itself is parsed and interpreted.

You should also, however, be aware of the rôle of the doctype declaration, and not think that it affects the HTML vs. XHTML thing

domedia
03-20-2006, 02:01 PM
You're right on raman.