CSS Code Add Space Between Inline Elements

CSS Code Several Ways to Control and Add Space Between Inline or Inline Block Elements

Home Short:

Surround the inline or inline-block elements you want to add spacing to with a div and set the parent div word-spacing property

Remember that this also sets the word-spacing property for any elements within .container so you will have to reset the css word-spacing property for those elements.

inline elements
with 20px space
via word-spacing




Using margin-right property on inline elements to control spacing between inline elements

Now you might think this is no good because you have already set the margin property on the inline elements to center them on the screen. You can still set the margin right property to create space between inline elements like so:

inline elements
with 20px space
via margin-right




Use flexbox with gap property to add space between inline elements

inline elements
with 20px space
via flexbox gap

Note that with this method you can't use margin:15px auto; etc to center the inline items because that will change the spacing between. Instead use justify-content:center; to center the inline items horizontally.

S
H
A
R
E