1
<style>
html, body {
    height: 100%;
}

img.one {
    height: auto;
    width: auto;
}

img.two {
    height: 50%;
    width: 50%;
}
</style>

In the css above, when I take out the height property of body and html something seems to happen but I don't understand what. What is the purpose of setting the height to 100% for body and html?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Deeven
  • 413
  • 1
  • 5
  • 14

2 Answers2

2

Add border to see the differences.

html, body {
    height: 100%; /* Ex: Change it 100% to %75 */
    border: 2px solid red;
}

When you done you can remove the line.

Mehmet
  • 217
  • 3
  • 12
1

If you remove the height from html, body then img.two { height: 50%; } has no reference height any more. 50% of what should it then be?

connexo
  • 53,704
  • 14
  • 91
  • 128