Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding doctype html breaks layout height

Tags:

html

css

I was developing a page recently, and after finding that everything worked properly noticed that I hadn't added the <!doctype html> tag at the top. Upon adding it, the layout ignored the height.

I stripped it down to the most basic layout to see what was wrong and the problem persists. Is what I'm doing inconsistent with HTML5?

The working source code

What it looks like

like image 784
bezi Avatar asked Jun 26 '13 19:06

bezi


2 Answers

You should add the code to your post or it will get closed. Also, something on codepen or jsfiddle would work better, so that we can actually see the results, rather than pastebin.

Add this to your CSS:

html, body {
  height: 100%;
  min-height: 100%; /* for firefox */
}
like image 129
Xarcell Avatar answered Nov 02 '22 02:11

Xarcell


You have to set the height of your tag

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
}
like image 40
Rob K Avatar answered Nov 02 '22 01:11

Rob K