Jump to content

Archived

This topic is now archived and is closed to further replies.

Wuhtzu

Which doctype to use?

Recommended Posts

Hey

I'm having trouble choosing the right doctype for my html files. My problem is that when I include a doctype, like [b]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">[/b] some of my css doesn't work.

It is the height property for a table that doesn't work:

[b]style.css[/b]
[code]
table.table{
  width: 100%;
  height: 100%;
  border-style: solid;
  }
[/code]

[b]html file[/b]
[code]
<html>

<head>
  <link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>

<table class="table">
  <tr>
    <td>skid mig i munden
    </td>
  </tr>
</table>

</body>
</html>
[/code]

The result can be seen here:

http://wuhtzu.dk/random/doctype/nodoctype.html
http://wuhtzu.dk/random/doctype/doctype.html

When the doctype is specified the [b]height: 100%;[/b] doesn't apply. I have been looking at this list for hours http://www.w3.org/QA/2002/04/valid-dtd-list.html and eventually tryied almost all of them without any luck.


Which doctype should i choose?


Best regards
Wuhtzu

Share this post


Link to post
Share on other sites
Sorry for asking such a dumb question. It is of course me who should write according to the doctype and not the other way round. Sedondly the page is viewed correctly when the <!DOCTYPE> is specified -> height 100% is 100% of the parent element, which is <body> and <body> doesn't fill the browser windows vertically.

Wuhtzu

Share this post


Link to post
Share on other sites
I would use XHTML 1.1: [code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">[/code]

Share this post


Link to post
Share on other sites
Why use the xhtml-doctype when it isn't xhtml?

Share this post


Link to post
Share on other sites
Well it would be better if you changed from HTML to XHTML. There is not that much difference, but XHTML is better. As far as I can see, the code you posted do already follow the XHTML 1.1 rules (or whatever to call it).

[url=http://www.w3.org/TR/xhtml11/]More info about XHTML 1.1[/url]

Share this post


Link to post
Share on other sites
To conform to XHTML, you would have to change your link tag so it closes .. ="style.css"> would become ="style.css" />

Share this post


Link to post
Share on other sites
Thanks for the advice, I'll concider to validate the code as both html 4.01 and xhtml 1.1 :)
Of course the posted code is just an ultra simple example, but it was during the height=100% of a table i noticed the problem...

Wuhtzu

Share this post


Link to post
Share on other sites
Actually, the reason most of us are starting to use XHTML is because it gets us away from using HTML tags that are eventually going to be obsolete. It helps break you of being lazy and using junk code that MS loves so much - I am now in the habit of closing all tags.

It is important, particularly when using css, because if you don't close a tag, that style will bleed into the next tag.

If you are converting a huge number of old html to make them valid, it may be better to start with using html 4 transitional.

But remember, the doctype is only the first step. You must make sure you actually then write valid code for that particular doctype.

And for any web developer that means using two great tools.

1. the w3c html validator [url=http://validator.w3.org/]http://validator.w3.org/[/url]

2. Firefox with the webdeveloper toolbar extension. I couldn't imagine life online without this fabulous toolbar.

Share this post


Link to post
Share on other sites
If you must use a doctype, stick with 4.01 transitional so that you don't break everything -- and HTML will never be obsolete, so don't move to XHTML unless you actually know why you should bother.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.