Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does 'height: 0;' mean in CSS?

Tags:

html

css

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.

like image 313
NawazSE Avatar asked Sep 14 '15 12:09

NawazSE


People also ask

What does height 100 do in CSS?

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.

What does height in CSS do?

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.

Why is height 0 in HTML?

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.

What does HTML height 100% mean?

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.


2 Answers

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>
like image 188
alamin Avatar answered Sep 30 '22 16:09

alamin


"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.

like image 31
WingmanImd Avatar answered Sep 30 '22 15:09

WingmanImd