Having trouble with setting font-size styles for inline elements, causing unexpected gaps to appear. Despite finding related questions on this issue, I have yet to discover a solution that fits my specific case.
Here is the code in question:
<!doctype html>
<html>
<style>
.container {
font-size: 40px;
}
p {
margin: 0;
}
.small {
font-size: 16px;
}
</style>
<body>
<div class="container">
<p>Big text</p>
<p>
<span class="small">
Small text
</span>
</p>
<p>
<span class="small">
Small text
</span>
</p>
</div>
</body>
</html>
Is there a way to eliminate the additional vertical gaps without altering the existing HTML markup and only applying new CSS to the container div
and its children?
Attempts at using vertical-align:top
and line-height:0
have not yielded the desired outcome.
The desired result:
https://i.sstatic.net/GTo1j.png
The current output: