I am working with some old code of css. At many places they have declared height as height: 0;. what this 0 means and in which unit it is?
Can anyone help me out.
height: 100% gives the element 100% height of its parent container. height: auto means the element height will depend upon the height of its children.
The height CSS property specifies the height of an element. By default, the property defines the height of the content area. If box-sizing is set to border-box , however, it instead determines the height of the border area.
Height = 0 because the parent of the elements have 0 height, so make sure your parent, which is body here have 100% height or else. Save this answer.
For years, the answer was the following: html { height: 100%; } body { min-height: 100%; } This allows the HTML element to reference the parent viewport and have a height value equal to 100% of the viewport value.
in css height means the physical height of an element.
it is same as height:0px
or height:0%
.
suppose the following html elements one is having a property height:0;
and another is having a property height:100px
let's see what happen
#me {
height: 0;
background-color: #333;
}
#me2 {
height: 100px;
background-color: #333;
color: white;
}
<div id="me" style="">this is an element</div>
<br/>
<div id="me2" style="">this is an element</div>
"0" doesn't need an unit as height:0;
is the same as height: 0px;
or height: 0%;
height:0;
The result really depends on what element is targeted: EX:
#parentdiv{height:0;}
This just maked the parent div is 0px in height, but that doesn't mean that the child div will not show up, that will only happen if overflow:hidden; would be used also. So it really depends on what element it was appended to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With