Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly does the 'auto' value mean for the CSS height property?

Tags:

html

css

height

w3schools says that for height:

auto : The browser calculates the height. This is default

But what does “browser calculates the height” mean? Does it mean it just simply sums up the contained elements’ heights? Is this always calculated with the same method for all browser?

like image 449
pencilCake Avatar asked Oct 27 '11 09:10

pencilCake


1 Answers

What does it mean browser calculates the height?

It means the browser will make the element's height sufficient to fit its content.

Does it mean it just simply sums up the contained elements heights if they are up on each other?

Nope, it is more complicated than that, but I'm sure that is part of it.

Is this always calculated with the same method for all browsers?

No, there are generally small variances. You should calculate the element's height in JavaScript if you intend to perform calculations based on it, don't assume it will have the same height on all browsers.

like image 114
alex Avatar answered Nov 15 '22 04:11

alex