0

While learning CSS , I had always read that in case of block level elements Their default height is dependent on the height of its content itself

So only fixed sizes in px generally work for height eg. div { height: 500px }

Hence if you ever define height in percentages eg. div { height: 65% } won't take any effect

But literally everywhere i see height: 100%; being used for so many elements

Then how come using value 100% ( it too being a percentage ) for height is valid when the height is defined by content as explained already ?

I think i am missing something , can someone please explain

Edit The knowledge that percentages for height won't work was taken from a stack overflow answer only You may read it here here - Please see the accepted answer

Badal Singh
  • 479
  • 8
  • 24
  • The dupe link explains well how percentage on a `height` works. – Asons Sep 27 '19 at 04:55
  • 2
    [Maybe this example will help illustrate some things](https://jsfiddle.net/rxgzn286/). Remember that the `` and `` are elements with height too! – misterManSam Sep 27 '19 at 05:18

0 Answers0