overflow
apply to only block level element ref and the content of inline element cannot overflow since you cannot have it's height smaller than its content due to the fact that you cannot define height on inline element and the height is automatically defined by the content ref
Adding border will clearly show this:
.large {
font-size: 50px;
line-height: 1;
}
.overflow {
overflow: hidden;
border:1px solid green;
}
body > div {
margin:20px;
outline:2px solid red;
}
<body>
<div class="overflow large">
Testing: pPgG
</div>
<div>
<span class="overflow large">
Testing: pPgG
</span>
</div>
</body>
Notice how the span with its content is overflowing the div and it's not the content inside the span overflowing the span.
Even if you set line-height:0
you will only restrict the height of the block element and never the span element:
.large {
font-size: 50px;
line-height: 0;
}
.overflow {
overflow: hidden;
border:1px solid green;
}
body > div {
margin:50px;
outline:2px solid red;
}
<body>
<div class="overflow large">
Testing: pPgG
</div>
<div>
<span class="overflow large">
Testing: pPgG
</span>
</div>
</body>
Related question to understand how height is caclulated and the difference between block and inline element: How to determine height of content-box of a block and inline element