0Pricing
Tailwind CSS Academy · บทเรียน

ความสูงบรรทัดและระยะห่างตัวอักษร

ควบคุมความอ่านง่ายด้วยยูทิลิตี leading-* สำหรับความสูงบรรทัด และยูทิลิตี tracking-* สำหรับระยะห่างตัวอักษร

ความสูงบรรทัดและระยะห่างตัวอักษร เป็นบทเรียน Tailwind CSS Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Tailwind CSS Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Tailwind CSS Academy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Why Line Height Matters

Line height is the space between lines. Too tight feels cramped, too loose feels scattered. Getting it right makes long text noticeably easier to read.

Tailwind's leading-* Utilities

Set it with the leading-* utilities: leading-tight (1.25), leading-normal (1.5), leading-relaxed (1.625), leading-loose (2.0). The name comes from old print type.

<p class="leading-tight">Tight: good for headings</p>
<p class="leading-normal">Normal: default for most text</p>
<p class="leading-relaxed">Relaxed: comfortable for body text</p>
<p class="leading-loose">Loose: for spacious editorial layouts</p>

Leading for Headings vs Body

Use leading-tight for headings, since big text already has room, and leading-relaxed for body, which needs more breathing space. leading-normal is a safe default.

<h1 class="text-4xl font-bold leading-tight text-gray-900">
  A Two-Line Heading That
  Stays Tightly Together
</h1>
<p class="text-base leading-relaxed text-gray-600 mt-4">
  Body paragraph text benefits from more line spacing.
  It makes long passages easier to follow line by line.
</p>

Fixed Leading Values

Tailwind also has fixed leading: leading-3 to leading-10 set exact pixel heights. Reach for these in tables or dense UI where you need precise spacing.

<p class="leading-3">Very tight (12px)</p>
<p class="leading-5">Compact (20px)</p>
<p class="leading-7">Comfortable (28px)</p>
<p class="leading-10">Spacious (40px)</p>

Introduction to Letter Spacing

Letter spacing, or tracking, is the gap between characters. Tight tracking feels modern on big headings; wide tracking suits short labels like badges and tags.

Tailwind's tracking-* Utilities

Control it with tracking-*: from tracking-tighter and tracking-tight, through normal, to tracking-wide and tracking-widest. Negative pulls in, positive spreads out.

<p class="tracking-tighter">Tighter: editorial large headings</p>
<p class="tracking-normal">Normal: default body text</p>
<p class="tracking-wide">Wide: comfortable subheadings</p>
<p class="tracking-widest">Widest: UI labels and badges</p>

Tracking for Display Headings

Big display headings almost always want tracking-tight or tracking-tighter. At large sizes the default spacing feels loose, and tightening it looks polished.

<!-- Without tracking adjustment -->
<h1 class="text-6xl font-bold">Feels Loose</h1>

<!-- Professional: tighter tracking at large sizes -->
<h1 class="text-6xl font-bold tracking-tight">Feels Cohesive</h1>

Tracking for UI Labels

For uppercase UI labels, try text-xs font-semibold uppercase tracking-wider text-gray-500. The extra spacing offsets how cramped uppercase letters can feel.

<!-- Dashboard section label -->
<span class="text-xs font-semibold uppercase tracking-wider text-gray-500">
  Recent Activity
</span>

<!-- Badge -->
<span class="bg-green-100 text-green-700 text-xs font-semibold uppercase tracking-wider px-2 py-1 rounded-full">
  Active
</span>

Combining Leading and Tracking

Leading and tracking shine together. A pull quote might use leading-relaxed tracking-wide for an open feel; a metric label uses tracking-widest leading-none.

<!-- Pull quote style -->
<blockquote class="text-2xl italic font-light leading-relaxed tracking-wide text-gray-600">
  'Design is intelligence made visible.'
</blockquote>

<!-- Dashboard label style -->
<p class="text-xs font-bold uppercase tracking-widest leading-none text-gray-500">
  Revenue MTD
</p>

Word Spacing Utilities

Tailwind even has word spacing: word-spacing-tight, normal, and wide adjust the gap between words. You will need it rarely, mostly for justified or display text.

<p class="word-spacing-wide text-gray-700">
  Extra space between each word in this sentence.
</p>

Practical: Blog Article Styles

A polished blog article: text-4xl font-bold leading-tight for the title, text-xl font-light for the subtitle, text-lg leading-relaxed for body, max-w-prose to wrap.

<article class="max-w-prose mx-auto px-4">
  <h1 class="text-4xl font-bold leading-tight tracking-tight text-gray-900 mb-2">
    Article Title
  </h1>
  <p class="text-xl font-light leading-snug text-gray-500 mb-8">
    A compelling subtitle for the article.
  </p>
  <p class="text-lg leading-relaxed text-gray-700">
    The body of the article content goes here.
  </p>
</article>

Quick Check

Quick check! See how spacing settled in. 📏

Lesson Recap

Nice! leading-* sets line height, tracking-* sets letter spacing, and headings like tight tracking while body likes relaxed leading. Next up: alignment and decoration.

คำถามที่พบบ่อย

บทเรียน “ความสูงบรรทัดและระยะห่างตัวอักษร” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “ความสูงบรรทัดและระยะห่างตัวอักษร” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Tailwind CSS Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Tailwind CSS Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “ความสูงบรรทัดและระยะห่างตัวอักษร”

ควบคุมความอ่านง่ายด้วยยูทิลิตี leading-* สำหรับความสูงบรรทัด และยูทิลิตี tracking-* สำหรับระยะห่างตัวอักษร คุณปฏิบัติ Tailwind CSS Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Tailwind CSS Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Tailwind CSS Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน

บทเรียน “ความสูงบรรทัดและระยะห่างตัวอักษร” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Tailwind CSS Academy นี้ได้ไหม

ได้ บทเรียน Tailwind CSS Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. ขนาดและน้ำหนักตัวอักษร
  2. สีข้อความและความทึบ
  3. ความสูงบรรทัดและระยะห่างตัวอักษร
  4. การจัดแนวและการตกแต่งข้อความ
← กลับไปที่ Tailwind CSS Academy