Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why margin top does not work in Tailwind CSS?

I am trying to top margin mt-10 in first but it is not working. However, if I give that expression as mx-10- it is working.

<div className="font-bold text-white">
  <a id='first' className="mt-10">Explore</a>
  <a id='second' className="mx-4">Collections</a>
  <a id='third' className="mx-4">Profiles</a>
</div>
like image 213
Thompson Billy Avatar asked May 24 '26 18:05

Thompson Billy


1 Answers

When it comes to margins and padding, browsers treat inline elements differently. You can add space to the left and right on an inline element, but you cannot add height to the top or bottom padding or margin of an inline element. Give the <a> tags an inline-block class to solve this problem.

<div className="font-bold text-white">
  <a id='first' className="mt-10 inline-block">Explore</a>
  <a id='second' className="mx-4 inline-block">Collections</a>
  <a id='third' className="mx-4 inline-block">Profiles</a>
</div>

Related Links: Margin Properties

like image 159
mo3n Avatar answered May 27 '26 08:05

mo3n



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!