Tailwind CSS - Font Smoothing


Font smoothing in Tailwind CSS makes text smoother by adjusting its appearance using predefined classes, thereby improving text appearance on web pages.

Tailwind CSS Font Smoothing Classes

Below is a list of Tailwind CSS classes that specify different font smoothing options.

Class CSS Properties
antialiased -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
subpixel-antialiased -webkit-font-smoothing: auto;
-moz-osx-font-smoothing: auto;

Functionality Of Tailwind CSS Font Smoothing Classes

  • antialiased: This class smooths text edges on screen using anti-aliasing, improving text clarity.
  • subpixel-antialiased: This class adjusts how each pixel on a screen displays text to achieve a smoother appearance with subpixel anti-aliasing.

Tailwind CSS Font Smoothing Class Examples

Below are examples of Tailwind CSS Font Smoothing classes, which create smoother and clearer text on web pages by adjusting how fonts are rendered using predefined classes.

Tailwind CSS for Antialiased and Subpixel-Antialiased Font Smoothing

This example uses Tailwind CSS to style two paragraphs showing different font smoothing techniques that adjust how fonts are rendered on web pages.

<!DOCTYPE html>
<html lang="en">
<head> 
   <script src="https://cdn.tailwindcss.com"></script>
</head>
 
<body class="p-4">
    <h1 class="text-2xl font-bold mb-4">
        Tailwind CSS Font Smoothing
    </h1>  
    <p class="underline">Using antialiased font</p>
    <p class="antialiased text-lg mb-4">
        This text uses antialiased font smoothing.
    </p>
    <br>
    <p class="underline">Using subpixel anti-aliasing</p>
    <p class="subpixel-antialiased text-lg">
        This text uses subpixel anti-aliasing
        for font smoothing.
    </p>
</body>

</html>