Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML 5 Doctype messes up layout

Tags:

html

css

My website was almost 100% done when I checked it to the W3C Validator. Got an error saying that I didn't declare a Doctype. So I added the HTML 5 <!DOCTYPE html> . OK, the error is gone. But why does the layout becomes so messed up like?

Please view it below.
http://itsdaffa.16mb.com/ --> Without Doctype
http://itsdaffa.16mb.com/error.html --> WITH Doctype

I have stumbled upon some answers about similar issues but couldn't really understand since mostly are their code's specific error. In this question for example, the user solved his problem by removing negative right property values while I don't have any in my code.
I am a complete beginner to this, in fact this is the first website I'm building from scratch. I desperately need help. Thanks :)

like image 682
Daffa Alif Pratama Avatar asked Jun 07 '15 14:06

Daffa Alif Pratama


1 Answers

You will need to put this in your CSS:

html, body {
    height: 100%
}

The reason being when you add the doctype, then you are switching from quirks mode to standards mode. In standards mode the html and body elements do not default to 100% height.

See explanation here

like image 122
Jackson Avatar answered Oct 24 '22 05:10

Jackson