Tailwind CSS - Content


Tailwind CSS Content includes predefined classes that make it easier to style and organize webpage content. These classes specifically manage content within pseudo-elements (:before and :after) in CSS.

Tailwind CSS Content Classes

Below is a list of Tailwind CSS Content classes with properties for efficient styling and organization of webpage content.

Class CSS Properties
content-none content: none;

Functionality Of Tailwind CSS Content Classes

  • content-none: Tailwind CSS does not have a content-none class. It uses content-* classes with 'after' and 'before' to manage text insertion.

Tailwind CSS Content Class Examples

Below are examples of Tailwind CSS Content classes that show how to style and manage content effectively with predefined classes.

Using Tailwind CSS After Content Attributes

This example shows how Tailwind CSS after content attributes can append additional content after a link's anchor text. These classes enable the insertion of extra elements or text into the pseudo-element following specific content.

Example

 
<!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 Content
    </h2>
    <h3 class="underline font-bold mb-6">
        Controlling Content with After Attributes
    </h3>
    <p>
        This paragraph is followed by a 
        <a href="https://www.tutorialspoint.com" 
        class="after:content-['Click me'] bg-blue-200">
        link to visit a website</a>.
    </p>
</body>

</html>

Controlling Content Insertion Before Main Content

This example shows Tailwind CSS Content classes, which are used to dynamically set the content for a pseudo-element using the 'before' attribute, displaying it before the content begins.

Example

<!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 Content
    </h2>
    <h3 class="underline font-bold mb-6">
        Controlling Content Insertion Before Main Content
    </h3>
    <div before="Inserting Hello before content begins!" 
        class="before:content-[attr(before)] border p-4">
            Here the main content starts...
    </div>
</body>

</html>