How to remove the whitespace between inline-block elements
- Published on
- Separator
- •
- Reading time
- 2 min read
I was struggling with this issue when stepping in front-end development career and of course, I also looked for a solution on Google. I finally figured out variety of methods to solve this one. Let’s get started to remove the whitespace with an example below.
So, here we go:
Original result:
font-size
Fixed result:
It’s not such a good idea to solve the problem by using font-size
cause it doesn’t work on 100% browsers.
letter-spacing
Fixed result:
margin-right
Fixed result:
word-spacing
Fixed result:
word-spacing: -1ch
works for fonts which have characters is 1ch
wide and works in Firefox 10+, Chrome 27+, almost works in IE9+.
Conclusion
We have lots of tricks to remove the whitespace between inline-block
elements, but I only stay focused to solve it by using CSS. In additional, as you probably known, we also have several other methods to alternate instead of using display: inline-block
.
Stay tuned for the next post. Thanks for reading :)