0

This might be a silly question. However, I couldn't find the exact reason for this question. Whenever I set 100% to width and height of a div it doesn't take this behaviour but when I set the width and height of the Html and body elements to 100% then the div with 100% size works perfectly. What is the reason behind it? Thanks in advance :)

Harish
  • 1,193
  • 6
  • 22
  • 45
  • 1
    you cant fit big box in small box same way you if your html body is smaller than your div. it wont fit in it so you need to use 100% width to body than you can give 100% width to div. – Mudassar Saiyed Nov 19 '16 at 10:06
  • In most browser's there's a default styling for `` and/or `` which includes a bit of margin, see here: http://stackoverflow.com/a/19101740/1781026 & http://stackoverflow.com/q/13127887/1781026 – chrki Nov 19 '16 at 10:06
  • Thank you @MudassarSaiyed. Now I'm clear. – Harish Nov 19 '16 at 10:10

1 Answers1

3

Just ask yourself: 100% of what? The answer is: 100% of the parent element, which in many situations is the body, whose parent again is the HTML tag.

Johannes
  • 64,305
  • 18
  • 73
  • 130