doctype definition and css

M

Martin Nadoll

Hello,

i am using Dreamweaver MX 2004 to develop my php and html-sites.
Dreamweaver includes a doctype-definition when creating a new page, in my
case:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

Now i needed to make a table with 100% height to show the content vertical
centered on my screen.
(or is there a solution with css to center content vertical on screen?)

<table id="myTable">....... </table>
i used a id referenced style for that:
#myTable { height:100%; }

didn't work.
When i remove the doctype-definition, everything works fine.

What is the reason for that?
Is a doctype definition important?
What happens, if i remove it?
Is there another definition i can use, to bring that style to work?

Because i'm not sure, this is the right place, i will ask the same question
in a css group too.

Thanks for any help,
Martin Nadoll
 
S

Steve Pugh

Martin Nadoll said:
i am using Dreamweaver MX 2004 to develop my php and html-sites.
Dreamweaver includes a doctype-definition when creating a new page, in my
case:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

Yeah, Dreamweaver is a bit behind the times and defaults to
Transitional rather than Strict. You can configure it to include a
Strict doctype instead.
Now i needed to make a table with 100% height to show the content vertical
centered on my screen.

Sounds like you're misusing a table.
(or is there a solution with css to center content vertical on screen?)

(I presume you mean viewport when you say screen, the centre of the
screen may not be inside the browser window at all).

Yes. Two solutions, one doesn't work in IE and the other can lead to
content being placed inaccessibly off the viewport for users with
small viewports.
<table id="myTable">....... </table>
i used a id referenced style for that:
#myTable { height:100%; }

didn't work.
When i remove the doctype-definition, everything works fine.

What is the reason for that?

height: 100% is calculated as 100% of the parent element. The parent
element in this case is the body which in the absence of a specified
height will only be as tall as it's content. So the table is as tall
as the body and the body is as tall as the table. So 100% = as small
as needed by the table's contents.
Is a doctype definition important?

Yes. No. Depends.

In theoretical terms the doctype is very important, but in practical
terms browsers don't use it for it's official purpose. However, they
do use it as a switch to determine whether they will lay out the page
in accordance with the spec or in accordance with the behaviour of
older browsers. This switching is done on the basis of the text of the
doctype rather than the version of HTML being referenced by the
doctype (i.e. there are some cases where two different doctypes, both
for the same version of HTML will trigger different rendering modes).
What happens, if i remove it?

The browser moves into "quirks mode" whereby it starts emulating lots
of bugs from older browser versions. Such as calculating heights
incorrectly.
Is there another definition i can use, to bring that style to work?

In addition to what you have, add:
html, body {height: 100%;}

Now the body element is as tall as the html element and the html
element is as tall as the viewport. So the table element will now be
as tall as the viewport.
Because i'm not sure, this is the right place, i will ask the same question
in a css group too.

And where would you like your answers? Don't multipost, crosspost with
one group set for followups.

Steve
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top