Tailwind CSS - Typography


Tailwind CSS Typography covers a wide range of predefined classes that helps to style text directly on web pages. It includes options for font selection, text size, line spacing, and more.

Tailwind CSS Typography Reference

The following topics can help you create effective typography for your elements.

Topic Description Example
Tailwind CSS - Font Family Font family is used to define the style and appearance of characters on web pages.
Tailwind CSS - Font Size Font size controls how large and small text appear on web pages.
Tailwind CSS - Font Smoothing Font smoothing makes text look smoother and easier to read on web pages.
Tailwind CSS - Font Style Font style changes how text looks by adjusting its appearance.
Tailwind CSS - Font Weight Font weight controls how thick or thin and how bold or light text appears on web pages.
Tailwind CSS - Font Variant Numeric Font variant Numeric changes how numerical characters appear in text using Tailwind CSS.
Tailwind CSS - Letter Spacing Letter spacing controls the distance between characters in text using Tailwind CSS.
Tailwind CSS - Line Clamp Line Clamp limits text to a fixed number of lines in Tailwind CSS.
Tailwind CSS - Line Height Line Height sets the vertical distance between lines in text using Tailwind CSS.
Tailwind CSS - List Style Image List Style Image replaces default bullets with custom images in lists using Tailwind CSS.
Tailwind CSS - List Style Position List Style Position controls the positioning of list item markers by setting their alignment within the list.
Tailwind CSS - List Style Type List Style Type sets the type of bullet points or markers in lists using Tailwind CSS.
Tailwind CSS - Text Align Text Alignment sets the horizontal position of text using Tailwind CSS.
Tailwind CSS - Text Color Text color defines the color of text by applying various color classes within Tailwind CSS.
Tailwind CSS - Text Decoration Text Decoration applies styling effects such as underline, overline, and line-through to text in Tailwind CSS.
Tailwind CSS - Text Decoration Color Text Decoration Color changes the color of text styling like underline and line-through in Tailwind CSS.
Tailwind CSS - Text Decoration Style Text Decoration Style is responsible for designing text styling effects such as underline, line-through, and more.
Tailwind CSS - Text Decoration Thickness Text Decoration Thickness controls the boldness or thickness of text styling like underline ,line-through and others.
Tailwind CSS - Text Underline Offset Text Underline Offset controls the vertical distance between underlines and text characters using Tailwind CSS.
Tailwind CSS - Text Transform Text Transform converts text to uppercase, lowercase, or capitalize in Tailwind CSS.
Tailwind CSS - Text Overflow Text Overflow controls how text is displayed when it overflows its container in Tailwind CSS.
Tailwind CSS - Text Wrap Text Wrap controls how text breaks and fits within specified dimensions in Tailwind CSS.
Tailwind CSS - Text Indent Text Indent defines how much space is added before the start of the first line of text in Tailwind CSS.
Tailwind CSS - Vertical Align Vertical Align controls how elements are vertically positioned within their containers using Tailwind CSS.
Tailwind CSS - Whitespace Whitespace controls the spacing between text elements in Tailwind CSS.
Tailwind CSS - Word Break Word Break defines the handling of long words and their wrapping in Tailwind CSS.
Tailwind CSS - Hyphens Hyphens control the insertion of hyphens into words to manage line breaks in Tailwind CSS.
Tailwind CSS - Content Content in Tailwind CSS controls which text or elements are added before or after an element.

Example of Tailwind CSS Typography

In the following example, we will cover some of the Tailwind CSS typography classes mentioned above.

Example 1

  
<!DOCTYPE html>
<html lang="en">
<head>
    <script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="p-4">
    <h2 class="text-2xl font-bold mb-6">
        Tailwind CSS Typography Examples
    </h2>
    <p class="underline font-bold mb-2">Using Font-Mono</p>
    <p class="font-mono mb-6">
        This paragraph uses a monospaced font styled with Tailwind CSS.
    </p>
    <p class="underline font-bold mb-2">Applying Underline Offset</p>
    <p class="underline underline-offset-8 mb-8">
        This paragraph has an underline with an offset of 8px.
    </p>
    <p class="underline font-bold mb-2">
        Applying Text Alignment and Line Height
    </p>
    <div class="max-w-md border border-black p-4">
        <p class="text-left leading-8 mb-2">
            <strong>Left-aligned text:</strong>
            Having a sense of purpose gives us direction and fulfillment.
        </p>
        <p class="text-right leading-8">
            <strong>Right-aligned text:</strong>
            Having a sense of purpose gives us direction and fulfillment.
        </p>
    </div>
    <p class="text-blue-700">
        <strong>In this example, we use classes for font, 
        underline offset, text alignment, line height, 
        and apply blue text color to this text.</strong>
    </p>
</body>

</html>

Example 2

In the example below, we'll take a closer look at some additional Tailwind CSS typography classes.

<!DOCTYPE html>
<html lang="en">
<head>
      <script src="https://cdn.tailwindcss.com"></script> 
</head>

<body class="p-4">
    <h2 class="text-2xl font-bold mb-6">
        Tailwind CSS Typography Examples
    </h2>
    <p class="underline font-bold mb-2">
        Applying Text decoration style and color
    </p>
    <p class="underline decoration-wavy decoration-red-500  mb-8">
        This paragraph has a wavy underline from text decoration style.
    </p>
    <p class="underline font-bold mb-2">
        Applying Letter Spacing
    </p>
    <p class="tracking-wider mb-6">
        This paragraph has wider letter spacing for better readability.
    </p>
    <p class="underline font-bold mb-2">
        Applying Text Indentation
    </p>
    <div class="max-w-xs border border-black p-4 mb-6"> 
        <p class="indent-8 mb-4">
            This paragraph has an indentation of 2rem
            (32px) from the left.
        </p>
    </div>
    <p class="underline font-bold mb-2">
        Applying  Word Break
    </p>
    <div class="max-w-xs border border-black p-4 mb-6"> 
        <p class="break-words">
            This paragraph text wraps where long words like<strong>
            pneumonoultramicroscopicsilicovolcanoconiosiss</strong>
            or URLs break to fit within the container.
        </p>
    </div>
    <p>
        <strong>This example uses classes for text decoration,
        color, indentation, word breaking, line height, 
        and letter spacing.</strong>
    </p>
</body>

</html>