Line Height Utilities
Line height utilities in Tailwind CSS are used to control the spacing between lines of text.
Proper line spacing improves:
- readability
- text clarity
- webpage appearance
- user experience
Tailwind provides predefined utility classes to manage line spacing easily.
Line Height Classes
| Class | Meaning |
|---|---|
leading-none |
No extra spacing |
leading-tight |
Tight spacing |
leading-normal |
Normal spacing |
leading-relaxed |
Relaxed spacing |
leading-loose |
Large spacing |
Example: Line Height
<!DOCTYPE html>
<html>
<head>
<title>Line Height Example</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="p-6 space-y-6">
<p class="leading-none bg-gray-100 p-4">
Tailwind CSS provides utility classes
for modern UI development.
</p>
<p class="leading-normal bg-gray-100 p-4">
Tailwind CSS provides utility classes
for modern UI development.
</p>
<p class="leading-loose bg-gray-100 p-4">
Tailwind CSS provides utility classes
for modern UI development.
</p>
</body>
</html>
Body Classes
<body class="p-6 space-y-6">
p-6
Adds padding around webpage content.
space-y-6Adds vertical spacing between paragraphs.
Tight Line Spacing<p class="leading-none bg-gray-100 p-4">
leading-none
Removes extra spacing between lines.
Text appears compact.
Normal Line Spacing<p class="leading-normal bg-gray-100 p-4">
leading-normal
Applies normal readable spacing.
Used for:
-
paragraph text
-
normal content
<p class="leading-loose bg-gray-100 p-4">
leading-loose
Creates large spacing between lines.
Used for:
-
articles
-
blogs
-
long content
Line Height Comparison
|
Class |
Typical Usage |
|---|---|
leading-none |
Compact text |
leading-tight |
Small paragraphs |
leading-normal |
Default content |
leading-relaxed |
Articles |
leading-loose |
Blogs and long text |
Advantages of Line Height Utilities
-
Improves readability
-
Better paragraph formatting
-
Professional typography
-
Cleaner webpage appearance
-
Easy spacing control
Summary
In this topic, we learned how line height utilities in Tailwind CSS control spacing between lines of text. We explored different line height classes and understood how they improve readability and webpage typography.
Keywords
Line Height Utilities, leading-none, leading-normal, leading-loose, Typography, Readability, Tailwind Typography, Text Spacing, UI Design, Modern Web Design, Frontend Development.