DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

Cover image for Tailwind CSS tutorial #19: Font Weight
Shubhangiโœจ
Shubhangiโœจ

Posted on

Tailwind CSS tutorial #19: Font Weight

In the article, we will go into detail on how to use font-weight.

Font Weight

Format

font-{weight}

Alignment Tailwind Class CSS Property
font-thin font-thin font-weight: 100;
font-extralight font-extralight font-weight: 200;
font-light font-light font-weight: 300;
font-normal font-normal font-weight: 400;
font-medium font-medium font-weight: 500;
font-semibold font-semibold font-weight: 600;
font-bold font-bold font-weight: 700;
Font-extrabold font-extrabold font-weight: 800;
Font-black font-bold font-weight: 900;

Setting the font weight

Control the font weight of an element using the font-{weight} utilities.

Code

<ul class="container mx-auto leading-none divide-y divide-gray-400 divide-dotted" style="font-family: Raleway">
  <li class="flex items-center justify-between px-4 py-2">
    <div>
      <div class="font-light text-5xl align-middle mb-2">Hello World</div>
    </div>
    <div class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">font-light   </div>
  </li>
  <li class="flex items-center justify-between px-4 py-2">
    <div>
      <div class="font-normal text-5xl align-middle mb-2">Hello World</div>
    </div>
    <div class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">font-normal  </div>
  </li>
  <li class="flex items-center justify-between px-4 py-2">
    <div>
      <div class="font-medium text-5xl align-middle mb-2">Hello World</div>
    </div>
    <div class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">font-medium  </div>
  </li>
  <li class="flex items-center justify-between px-4 py-2">
    <div>
      <div class="font-semibold text-5xl align-middle mb-2">Hello World</div>
    </div>
    <div class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">font-semibold</div>
  </li>
  <li class="flex items-center justify-between px-4 py-2">
    <div>
      <div class="font-bold text-5xl align-middle mb-2">Hello World</div>
    </div>
    <div class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">font-bold    </div>
  </li>
</ul>
Enter fullscreen mode Exit fullscreen mode

Full code:
The overall code will be attached to repo link.

Overall Output
Image description

Resources:
tailwind.css

Thank you for reading :), To learn more, check out my blogs on Flex Direction, Hackathons and Flex Wrap.
If you liked this article, consider following me on Dev.to for my latest publications. You can reach me on Twitter.

Keep learning! Keep coding!! ๐Ÿ’›

Top comments (1)

Collapse
 
j471n profile image
Jatin Sharma

You can also use Arbitrary values such as font-[700] or font-[1000]

Stop sifting through your feed.

Find the content you want to see.

Change your feed algorithm by adjusting your experience level and give weights to the tags you follow.