Categories
CSS

How to remove the space between inline/inline-block elements with CSS?

Spread the love

Sometimes, we want to remove the space between inline/inline-block elements with CSS.

In this article, we’ll look at how to remove the space between inline/inline-block elements with CSS.

How to remove the space between inline/inline-block elements with CSS?

To remove the space between inline/inline-block elements with CSS, we use flexbox.

For instance, we write

<p>
  <span> Foo </span>
  <span> Bar </span>
</p>

to add some elements.

Then we write

p {
  display: flex;
}

to make the p element a flex container with display: flex;.

Now the spans won’t have gaps between them.

Conclusion

To remove the space between inline/inline-block elements with CSS, we use flexbox.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *