My understanding is that width: 100% lets the element’s width be the same as its parent’s, whereas width: inherit does that only when the parent’s width is explicitly specified. Is this understanding correct?
If so, it looks to me that when width: inherit works, then width: 100% would always work, so you could always use the latter. Then, what is the purpose of writing width: inherit? When does it become useful?
If my understanding is wrong, what is the difference between the two?
Similarly with height.
See jsfiddle http://jsfiddle.net/bt5nj/2/ and http://jsfiddle.net/bt5nj/3/
width:inheritinherits width that defined by parent.HTML:
CSS:
This makes
childwidth 25%, but if I redefine it withwidth:100%it will define width ofchild50%.