Is there a way to eliminate unexpected spaces that appear between spans?
One attempt was made by setting font-size: 0
within the wrapper <div>
, which successfully removed spaces not only between <span>
tags but also within each <span>
tag.
.word-space {
color: white;
background-color: gray;
}
.letter-space {
color: white;
background-color: red;
}
.tried-with-font {
font-size: 0;
}
.tried-with-font span {
font-size: 18px;
}
<div class="word-space">
<span>My name </span>
<span>is </span>
<span>Antonio.</span>
</div>
<div class="letter-space">
<span>Sear</span>
<span>ch</span>
<span> Results.</span>
</div>
<h3>The result I tried:</h3>
<div class="tried-with-font">
<span>Sear</span>
<span>ch</span>
<span> Results.</span>
</div>
Seeking guidance on how to remove spaces between span tags while preserving spaces within each span tag.
The content within the span tags is subject to change dynamically.