Newbie: Placing DOCTYPE tag on HTML file screws up formatting

K

KS

I have just designed my first website from books I have read and resources
on the net. I designed several pages, but did not put the DOCTYPE tag at
the beginning, figuring I could put the tag in once I got the pages ready.
Everything is formatting and working correct until I put in the DOCTYPE tag,
then the formatting gets screwed up. I must have been mistaken to think the
DOCTYPE tag was useless except for validation purposes. I could probably
put my site on the web without the DOCTYPE tag and it would work fine. Can
anyone tell me why putting the DOCTYPE tag in my HTML file would screw up
the formatting and layout? Does anyone have any recommendations of what to
look for or what changes may need to be made? I'd appreciate the help.

KS
 
M

Michael Winter

Can anyone tell me why putting the DOCTYPE tag in my HTML file would
screw up the formatting and layout?

Omitting the DOCTYPE causes more recent browsers to enter into "quirks
mode". Simply put, this emulates the rendering bugs of older browsers when
they didn't conform to standards. These bugs were perpetuated to ensure
that legacy pages weren't broken when they were actually rendered
correctly.

As modern pages should validate[1] and you should aim to use HTML and CSS
as they are specified (rather than hacking solutions), you should force
the browser into "strict mode". One advantage of writing "correct"
documents is that they tend to render more predictably across the wide
range of user agents currently in use.
Does anyone have any recommendations of what to look for or what changes
may need to be made?

Googling for "quirks mode" will turn up a lot of information on the
subject, as will just "doctype".

Something else to add is that it's best, in my opinion at least, to test
your pages in browsers better than IE (assuming you don't already). Opera
and Mozilla do a much better job of showing how your pages should actually
look. IE tends to accept any old rubbish.

Mike


[1] See <URL:http://validator.w3.org/> and
<URL:http://jigsaw.w3.org/css-validator/>.
 
T

Toby Inkster

KS said:
Can anyone tell me why putting the DOCTYPE tag in my HTML file would
screw up the formatting and layout?

Your page was screwed up to begin with. The DOCTYPE fixed it. You just
happen to prefer how the screwed up version looked.
 
E

Eric B. Bednarz

There is no such thing; the document type declaration is a markup
declaration (even VB programmers should be able to grok that, since it
starts with the MDO ('markup declaration open') delimiter '<!' (!DUH)).

Because web browser vendors like M$, Mozilla and Opera don't care shit
about standards.
As modern pages should validate[1] and you should aim to use HTML and
CSS as they are specified (rather than hacking solutions), you should
force the browser into "strict mode".

You can't *force* IE/windows into "strict mode' (if you need a second
opinion, ask brucie what happens when he configures IE6 to connect
through the proxomitron :).
One advantage of writing
"correct" documents is that they tend to render more predictably
across the wide range of user agents currently in use.

IE6 has new, additional bugs in so-called 'standards compliant mode',
and M$ explicitly states that its results may not be compatible with
future versions of IE and should be avoided altogether for fixed media.

How cool.
Googling for "quirks mode" will turn up a lot of information on the
subject, as will just "doctype".

Googling for 'doctype' reveals predominantly BS.


(Mind me, this is hopeless anyway, but needs to be said now and then)
 
C

C A Upsdell

KS said:
I have just designed my first website from books I have read and resources
on the net. I designed several pages, but did not put the DOCTYPE tag at
the beginning, figuring I could put the tag in once I got the pages ready.
Everything is formatting and working correct until I put in the DOCTYPE
tag, then the formatting gets screwed up. I must have been mistaken to
think the DOCTYPE tag was useless except for validation purposes. I could
probably put my site on the web without the DOCTYPE tag and it would work
fine. Can anyone tell me why putting the DOCTYPE tag in my HTML file would
screw up the formatting and layout? Does anyone have any recommendations
of what to look for or what changes may need to be made? I'd appreciate
the help.

See http://www.upsdell.com/BrowserNews/res_doctype.htm
 
C

C A Upsdell

KS said:
I have just designed my first website from books I have read and resources
on the net. I designed several pages, but did not put the DOCTYPE tag at
the beginning, figuring I could put the tag in once I got the pages ready.
Everything is formatting and working correct until I put in the DOCTYPE
tag, then the formatting gets screwed up. I must have been mistaken to
think the DOCTYPE tag was useless except for validation purposes. I could
probably put my site on the web without the DOCTYPE tag and it would work
fine. Can anyone tell me why putting the DOCTYPE tag in my HTML file would
screw up the formatting and layout? Does anyone have any recommendations
of what to look for or what changes may need to be made? I'd appreciate
the help.

See http://www.upsdell.com/BrowserNews/res_doctype.htm
 
M

Michael Winter

On Wed, 10 Nov 2004 01:17:11 +0100, Eric B. Bednarz

[snip]
IE6 has new, additional bugs in so-called 'standards compliant mode',
[...]

Of course it does! It's IE.
Googling for 'doctype' reveals predominantly BS.

Googling for many things reveals predominantly BS, but at close to
midnight, I wasn't about to go check the content of the results. Call me
lazy, but sleep was a much more attractive idea. They seemed appropriate
and that was enough for me at the time.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top