James
James

Reputation: 11

Which doctype do I need?

I'm having an issue using the default VS doctype of

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

On my page I have a content box, which contains two divs, one floated left and the other floated right. The right floated div contains a height: 100%, however, this is never applied to match the height of the left div.

When I remove the doctype (bad, I know, but was just testing..) in IE8 the site looks like a dogs breakfast, whereas in Chrome and Firefox it looked exactly as I wanted it to.

Upvotes: 1

Views: 263

Answers (5)

Jon Matthews
Jon Matthews

Reputation: 13

Are you looking for the two divs to be identical in height? That will never be the case in standards mode because divs don't behave in the same way that table cells do. Table cells stretch to meet the dimensions of the table, divs are independent containers and do not behave in the same manner.

However there are solutions such as the Faux Column technique.

Here's a an article on the "Faux Columns" technique.

Upvotes: 0

Quentin
Quentin

Reputation: 944455

You should use a Doctype that:

  • Triggers standards mode (AKA strict mode)
  • Reflects the markup you are writing (which should usually be:)
    • HTML 4.01 Strict by default (or Transitional if you really need something from it)
    • HTML 5 if you are using features from the draft
    • XHTML 1.0 Strict (or Transitional if you really need something from it) if you have an XML toolchain with Appendix C normalisation at the end

The Doctype you have triggers standards mode, so you just need to figure out why browsers don't render content as you expect (there is a high chance that this will be due to errors in your CSS or markup that could be detected with a validator).

Upvotes: 1

pkoch
pkoch

Reputation: 2722

Not an answer: Search for two column layout.

Hint: search for "clear: both"-style solutions. (see http://www.quirksmode.org/css/clearing.html)

Upvotes: 0

&#193;lvaro Gonz&#225;lez
&#193;lvaro Gonz&#225;lez

Reputation: 146630

No DOCTYPE basically means that browsers will assume broken HTML and will try to guess so you'll never get coherent results. Just pick any spec of your choice (I try to avoid XHTML but it's a matter of taste) and run your code through an HTML validator until it has no errors.

Upvotes: 2

Chris Kempson
Chris Kempson

Reputation: 319

You should use whatever doctype fits the version of HTML you have been coding for. e.g <!DOCTYPE HTML> for HTML 5.

Upvotes: 3

Related Questions