How to fix Margin-Top not working for span element with CSS?

Spread the love

Sometimes, we want to fix Margin-Top not working for span element with CSS.

In this article, we’ll look at how to fix Margin-Top not working for span element with CSS.

How to fix Margin-Top not working for span element with CSS?

To fix Margin-Top not working for span element with CSS, we should make the span an inline block element.

For instance, we write

span {
  display: inline-block;
}

to make the span an inline block element.

Vertical margins can’t be applied to inline elements, which is what a span is by default.

Conclusion

To fix Margin-Top not working for span element with CSS, we should make the span an inline block element.

Leave a Reply

Your email address will not be published.