At the end of the previous lesson, we finally managed to place the Call to action elements perfectly in the center of our Hero Image. But the result is far from satisfactory.

First of all, you can hardly see anything here!

Step 1 - change the color of the text

Changing the text color in Tailwind is simple and we've talked about it in the previous lesson. To change it, for example, to white, just add the .text-white class to the element.

Then all elements that are its children will take this property. So add .text-white class to the parent element of our Call to action:

By the way - we can remove .p-10 class, which was added at the beginning of the previous lesson when the Navbar was covering Call to action. We don't need it anymore.

Slightly better, but still the contrast against the background is too weak. We'll get to that soon. Now let's try to improve the text itself a bit more.

Step 2 - change the size of the text

By default, the typography in Tailwind has no styling, which makes headings like h1, h2. h3 etc. and paragraphs look the same.

So to make the h1 element look like the most important heading on the page, we need to use the Tailwind classes.

In Tailwind you can control the font size of any element, including headings, with the text-{size} utility. For example:

  • text-xs: Extra small text size
  • text-sm: Small text size
  • text-base: Base text size (approximately equivalent to the browser default)
  • text-lg: Large text size
  • text-xl: Extra-large text size
  • text-2xl through text-9xl: Incrementally larger text sizes

So let's add .text-5xl class to h1 element in our Call to action, and .text-2xl to the h2:

It's taking shape, but there's still a lot of work to do.

Step 3 - change the weight of the text

You can control the font weight of any element, including headings, with the font-{weight} utility. Have a look at a list of classes you could use:

  • font-thin: Sets the font weight to 100
  • font-extralight: Sets the font weight to 200
  • font-light: Sets the font weight to 300
  • font-normal: Sets the font weight to 400
  • font-medium: Sets the font weight to 500
  • font-semibold: Sets the font weight to 700
  • font-extrabold: Sets the font weight to 800
  • font-black: Sets the font weight to 900

So let's add .font-semibold" class to h1 element in our Call to action, and .font-medium to the h2:

Better. Now let's center it.

Step 4 - center the text

It is true that we managed to center the Call to action in relation to the Hero Image, but still elements such as headings or the button are pressed to the left edge of the Call to Action. It would be nice if they were fully centered.

This is also very easy to do in Tailwind. Just add the text-center class to the Call to action element.

Now Call to action looks much better, but there is still a lot of work ahead of us.

Note: You can also try our Typography generator.

John Doe

About author

Michal Szymanski

Co Founder at TW Elements and MDBootstrap / Listed in Forbes „30 under 30" / Open-source enthusiast / Dancer, nerd & book lover.

Author of hundreds of articles on programming, business, marketing and productivity. In the past, an educator working with troubled youth in orphanages and correctional facilities.