Jump to content


Photo

Which doctype to use?


  • Please log in to reply
10 replies to this topic

#1 Wuhtzu

Wuhtzu
  • Members
  • PipPipPip
  • Advanced Member
  • 702 posts
  • LocationDenmark -> Fyn -> Aarup

Posted 30 September 2006 - 11:04 PM

Hey

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

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

style.css
table.table{
  width: 100%;
  height: 100%;
  border-style: solid;
  }

html file
<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>

The result can be seen here:

http://wuhtzu.dk/ran.../nodoctype.html
http://wuhtzu.dk/ran...pe/doctype.html

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


Which doctype should i choose?


Best regards
Wuhtzu
Feel free to correct me if I'm wrong.

Servage.net: Get 25 Gb of extra storeage by using this coupon code when buying their hosting service - http://www.servage.n...oupon=cust42005

#2 Wuhtzu

Wuhtzu
  • Members
  • PipPipPip
  • Advanced Member
  • 702 posts
  • LocationDenmark -&gt; Fyn -&gt; Aarup

Posted 01 October 2006 - 01:33 AM

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
Feel free to correct me if I'm wrong.

Servage.net: Get 25 Gb of extra storeage by using this coupon code when buying their hosting service - http://www.servage.n...oupon=cust42005

#3 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 01 October 2006 - 09:19 AM

I would use XHTML 1.1:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">


#4 Wuhtzu

Wuhtzu
  • Members
  • PipPipPip
  • Advanced Member
  • 702 posts
  • LocationDenmark -&gt; Fyn -&gt; Aarup

Posted 01 October 2006 - 12:44 PM

Why use the xhtml-doctype when it isn't xhtml?
Feel free to correct me if I'm wrong.

Servage.net: Get 25 Gb of extra storeage by using this coupon code when buying their hosting service - http://www.servage.n...oupon=cust42005

#5 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 01 October 2006 - 03:41 PM

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).

More info about XHTML 1.1

#6 FrOzeN

FrOzeN
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 01 October 2006 - 04:15 PM

To conform to XHTML, you would have to change your link tag so it closes .. ="style.css"> would become ="style.css" />

#7 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 01 October 2006 - 04:52 PM

Ah yeah, didn't notice.

#8 Wuhtzu

Wuhtzu
  • Members
  • PipPipPip
  • Advanced Member
  • 702 posts
  • LocationDenmark -&gt; Fyn -&gt; Aarup

Posted 01 October 2006 - 04:59 PM

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
Feel free to correct me if I'm wrong.

Servage.net: Get 25 Gb of extra storeage by using this coupon code when buying their hosting service - http://www.servage.n...oupon=cust42005

#9 dbrimlow

dbrimlow
  • Members
  • PipPipPip
  • Advanced Member
  • 712 posts

Posted 19 October 2006 - 02:45 PM

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 http://validator.w3.org/

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

I am always amazed by no matter how much I know, I know I don't know as much as I thought I knew.  - D. Brimlow.

#10 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 19 October 2006 - 04:45 PM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#11 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 19 October 2006 - 05:14 PM

try adding this to your CSS
html,body {
	height:100%;
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users