Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
Unwanted spaces between span elements wrapped in divs

span { background: green; }
<div><span> Hello World      </span></div>
<div><span> Foo bared        </span></div>
<div><span> Ariovistus Dummy </span></div>

There are little unwanted spaces between the span elements. I want to remove them with CSS, but how do I do it?

Well after some inspection I found that div with some content has more height than span with the same content.

let printHeight = tag => console.log(`The height of ${tag}: ${document.getElementsByTagName(tag)[0].getBoundingClientRect().height}px.`)

printHeight('div');
printHeight('span');
<div>Hello World</div>
<span>Hello World</span>

And probably that is the reason for the spaces. But why is that? And how to remove the spaces?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

span {
  background: green;
  display: inline-block;
}
<div><span> Hello World      </span></div>
<div><span> Foo bared        </span></div>
<div><span> Ariovistus Dummy </span></div>

Edited!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!