Can anyone explain why there is extra space above the first paragraph in this HTML and CSS code, but not the second or third? The line-height is consistent for all three paragraphs. How can I adjust it so that there is equal spacing around all three paragraphs?
I am encountering this issue on Chrome, not sure if it appears differently on other browsers.
.wrapper {
width: 175px;
border: 1px solid black;
font-size: 20pt;
}
.wrapper p {
margin: 0.5em 0 0 0;
background-color: orange;
line-height: 1.2;
word-wrap: break-word;
}
.wrapper p span {
display: inline-block;
}
<div class="wrapper">
<p style="text-align:center"><span style="font-size:0.5em"><span style="color:#00bcd4;">AAAAA & AAAAA</span></span></p>
<p style="text-align:center"><span style="font-size:0.5em">BBBBB · BBBBB · BBBBB BBBBB BBBBB</span></p>
<p style="text-align:center"><span style="font-size:0.5em"><span style="color:#00bcd4;">CCCCCCCC & CCCCCCCCCC</span></span></p>
<p>This is a paragraph without any spans, it needs to look correct too.</p>
</div>
Could someone verify if this is a browser-specific issue by looking at the provided image of the problem?
edit: Inserted another p
tag without any contained span
tags. This paragraph also should be correctly formatted.