Have you ever wondered why the apparent visual height of an element inside a border increases by 1 when a border is placed around it? The reported offsetHeight remains the same, equal to the desired height plus the border widths.
This issue becomes especially troublesome when trying to make an inner block element the same height as the outer element. You may notice that in some cases there is an extra 1px of height on the outer element, causing the inner element's background color to not fill the entire container:
#outer { height: 10px; width: 100px; border: 1px solid red; }
#inner { height: 10px; width: 50%; background-color: black; }
/* Setting #inner height to 100% has the same problem. */
<div id="outer"><div id="inner"></div></div>
Some devices may show a one-pixel-high gap between the black background and the red border.
https://i.sstatic.net/zkVkN.png
What causes this discrepancy, and how can you eliminate the "extra" bit of height inside the outer element so that the inner element occupies the full visual height of its container?
Could subpixel rendering be at play here?
Edit: This question isn't specifically about the box model. While understanding the box model, the concern is with the element being rendered with additional height inside its borders. Even Chrome's developer inspector may not display this extra height in its box model, but it's visible on screen.