Tailwind CSS Tutorial

Last Updated : 21 Aug, 2025

Tailwind CSS is a utility-first CSS framework that makes it easy to build custom designs without writing custom CSS. It allows you to apply individual utility classes directly in your HTML, which helps create fully customized layouts with minimal effort.

  • Tailwind provides many utility classes for building responsive and custom designs.
  • You can easily customize the framework to suit your needs via its configuration file.
  • Tailwind helps build seamless mobile-first and responsive designs.
  • Tailwind CSS has a feature that removes any unused CSS, improving performance.

To begin with Tailwind CSS, you need to install it using one of the methods. The easiest way is by using the CDN for quick setup.

Let us now take a look at our first code example.

HTML
<html>

<head>
    <link href="https://unpkg.com/[email protected]/dist/tailwind.min.css" 
    rel="stylesheet">
</head>

<body>
    <div class="h-full border-2 border-gray-200 
                border-opacity-60 rounded-lg 
                overflow-hidden">
        <div class="p-6 hover:bg-green-600 
                    hover:text-white transition 
                    duration-300 ease-in">
            <h1 class="text-2xl font-semibold mb-3">
                Hover
            </h1>
        </div>
    </div>
</body>

</html>

In this example:

  • Tailwind CDN: The link to the Tailwind CSS CDN is included in the <head> section of the HTML document to load the necessary CSS styles.
  • Hover Effect:
    • hover:bg-green-600: Changes the background color to green when the user hovers over the element.
    • hover:text-white: Changes the text color to white when hovered.
    • transition duration-300 ease-in: Applies a smooth transition effect for 300ms when hovering.
  • Responsive Design: The class names used here are mobile-first, ensuring they work well across different screen sizes.