I have a relatively simple setup inside part of my website:
<body>
<!-- ... a few <div> ... -->
<div class="root"><div><a><span></span></a></div></div>
<!-- ... a few </div> ... -->
</body>
- The
body
iswhite-space: nowrap
andfont-size: 0px
. - The outer
div.root
isdisplay: grid
with an explicit, staticwidth
andheight
. Single row/column ofmin-content
. - The inner
div
isdisplay: block
with no explicitheight
. - The
a
isdisplay: inline-block
. It has padding but no explicitheight
.line-height
andfont-size
are explicitly 0. - The
span
isdisplay: inline-block
withheight: 100%
. It is completely empty.
In the JSFiddle example the span
(which would be pictured as a red rectangle below) is 0 height regardless of the a
's padding. This is what I would expect.
But on my website the span
's height is controlled by the a
's padding! If the a
's padding is 100px then the span
's height is 100px. If the a
's padding is 0 then the span
's height is 0. If I explicitly set the a
's height to any value (including fit-content
) other than auto
the behavior goes away and the span
's height ignores the padding of a
(as in the JSFiddle example). Also, the div
doesn't seem to be accounting for the height of the span
/a
.
Neither border-box
or content-box
settings for box-sizing
(applied to all elements) make a difference (in both the JSFiddle and my website). The only notable difference between the example and my website is that on my website the above setup is contained within other elements. I've checked the whole ancestor chain for anything that might lead to this behavior, but I can't find anything.
Does anyone have any suggestions to try to find the culprit? Can anyone reproduce the behavior I'm seeing on my website?
Browser: Microsoft Edge 103.0.1264.62