Open In App

Introduction to Tailwind CSS

Tailwind CSS is a utility-first CSS framework that streamlines web development by providing a set of pre-designed utility classes. These classes enable rapid styling without writing custom CSS, promoting consistency and scalability. Tailwind’s approach shifts focus from traditional CSS components to functional classes, empowering developers to efficiently build responsive and visually appealing interfaces with minimal effort.

Why Tailwind CSS?



Advantages of Tailwind CSS:

Why use Tailwind over other CSS framework



Installation: There are two ways to use the CSS we can install them on our server or we can use the CDN link as well.

Method 1: Install Tailwind via npm

npm init -y

npm install tailwindcss

@tailwind base;
@tailwind components;
@tailwind utilities;

npx tailwindcss init

npx tailwindcss build styles.css -o output.css

Method 2: Using Tailwind via CDN

<link href=”https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css”rel=”stylesheet”>

Limitation of Tailwind: There are some limitations when CDN is used. Some of them are:

Example: In this example, we imports Tailwind CSS via CDN and applies margin to the body. It includes a heading styled with Tailwind utility classes and content about Tailwind CSS.




<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
   
    <!-- Tailwind CSS CDN link -->
    <link href=
"https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css"
          rel="stylesheet">
</head>
 
<body class="m-4">
    <h1 class="text-green-500 text-4xl font-bold">
        Geeksforgeeks
    </h1>
    <strong>Tailwind CSS Tutorial</strong>
    <p>
        You can use Tailwind CSS as a replacement of CSS,
        this is a framework that increase your pace to
        design any website.
    </p>
</body>
</html>

Output:

Supported Browser:


Article Tags :