Tailwind CSS is a utility-first CSS framework used to build custom and responsive user interfaces using predefined utility classes. Instead of writing custom CSS rules for every element, Tailwind CSS provides classes for layout, spacing, sizing, typography, colors, borders, effects, and other styling needs.
- Makes it easier to create responsive designs and customize the appearance of web pages directly in HTML.
- Follows a mobile-first approach for responsive designs.
- Helps reduce unused CSS in the final application.
Tailwind Hello World Program
Let's write your first Tailwind program. Here's a simple code example:
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<h1 class="text-3xl font-bold text-blue-600">
Hello World
</h1>
</body>
</html>
Why Learn Tailwind CSS?
- Provides utility classes that can be combined to create custom designs.
- Reduces the need to write separate CSS rules for individual components.
- Helps build websites, web applications, and landing pages.
- Supports creating reusable UI components with consistent styling.
Getting Started
Tailwind CSS can be added to a project using different setup methods. For quick experiments and simple examples, it can be added using a CDN.
- Introduction
- Installation
- Adding Tailwind CSS to HTML
- Setup with Create React App
- Configuring with Vite
- Installation with PHP
- Installation with Next.js
- Using with Django
- Configuration in AngularJS
Layout
Provides utility classes for controlling the layout and positioning of elements. These utilities can be used to control containers, display properties, positioning, overflow, and stacking.
- Container
- Box Sizing
- Display
- Float
- Clear
- Object Fit
- Object Position
- Overflow
- Overscroll Behavior
- Position
- Top/Right/Bottom/Left
- Visibility
- Z-index
Flexbox
Allows you to create flexible and responsive layouts using Flexbox.
Grid
Create complex grid layouts with ease using Tailwind's grid utilities.
Alignment
Provides utility classes to align content both horizontally and vertically.
Justify:
Align:
Place:
Spacing and Sizing
Provides utility classes for controlling the spacing, width, height, and size of elements.
Spacing
Sizing
Typography
Tailwind provides utilities to easily style text, including font sizes, weights, and line heights.
- Font Family
- Font Size
- Smoothing
- Style
- Weight
- Variant Numeric
- Letter Spacing
- Line Height
- List Style Type
- Placeholder Color
- Placeholder Opacity
- Text Alignment
- Color
- Opacity
- Decoration
- Transform
- Vertical Alignment
- Whitespace
- Word Break
Backgrounds
Tailwind's background utilities allow you to control backgrounds like images, colors, and gradients.
Borders
Easily customize borders with Tailwind's utilities for border color, radius, and width.
Border:
Divide:
Ring:
Offset:
Effects and Filters
Provides utility classes for adding visual effects such as shadows and opacity, and applying filters such as blur, brightness, contrast, grayscale, and saturation.
Effects:
Filter:
Backdrop:
Tables
Style tables easily with utilities that control layout and presentation.
Transitions and Animation
Add smooth transitions and animations to your UI elements with Tailwind's utility classes.
Transforms
Apply transformations such as scale, rotate, and translate with ease.
Interactivity
Tailwind provides utilities for enhancing user interactivity, such as cursor style and pointer events.
SVG
Style SVG elements with utilities for fill, stroke, and stroke width.
Prepare for your interviews with common questions related to Tailwind CSS, refer to: Tailwind CSS Interview Questions and Answers