OnlineCBT Logo OnlineCBT
CSS Tutorial
CSS · LESSON 17

Text Alignment, Spacing, and Transformation

By Ratan Updated: 15 Oct 2026

Control text-align, text-transform, letter-spacing, word-spacing, and text-indent.

Level: Beginner to Advanced
Duration: ~60 Mins Deep-Dive

Control text layout without altering its meaning

text-align controls inline content within a block. letter-spacing and word-spacing adjust spacing. text-transform changes presentation without rewriting the source text. Use these properties sparingly: readability matters more than a rigid visual pattern.

.article { text-align: start; }
.page-title { text-align: center; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.875rem;
}
.summary { line-height: 1.6; }

start follows the writing direction, making it more adaptable than always forcing left alignment. text-align:center centres the text inside the block; it does not centre the block itself. A fixed-width block can be centred with an appropriate layout rule or auto inline margins.

Do not confuse transforms

text-transform:uppercase changes displayed letter case where the script supports it. It is unrelated to transform:translate or rotate, which changes a box's visual geometry. Keep underlying content correctly spelled and capitalized rather than relying on CSS to repair editorial mistakes.

Spacing and scripts

Large letter spacing can damage readability and does not suit every script. Avoid applying a Latin-style uppercase/letter-spacing treatment indiscriminately to Hindi text. Use ordinary prose spacing for paragraphs and test the actual language and font.

Justification

text-align:justify may create distracting gaps, especially in narrow columns. If a design requires it, test line length, hyphenation behavior and language settings. A left/start-aligned paragraph is often a clearer default for screen reading.

Exercises

  1. Centre a heading and separately centre its containing card; explain the two operations.
  2. Apply uppercase only to a short English category label, not the full article.
  3. Compare a narrow justified paragraph with start alignment.
  4. Set the document language correctly and test mixed Hindi/English text for broken spacing.

हिन्दी संकेत: text-align block के अंदर text को align करता है। हर script पर letter-spacing बढ़ाना सही नहीं होता।

📝 Live Lesson Practice

HTML/CSS JavaScript Python C++ C PHP
⌨️ Practice Inputs (लाइव इनपुट भरें) (खाली होने पर RED, भरने पर GREEN underline)
💻 Code Editor (Monaco VS Code Engine)
👀 Live Preview
पता संपर्क करें

+91 7877547686

ई-मेल

onlinecbtportal@gmail.com

हेल्पलाइन नंबर

+91 7877547686


डाउनलोड करने के लिए क्लिक करें
Get it on Google Play

ऐप डाउनलोड करने
के लिए Google Play पर
उपलब्ध है

WhatsApp Chat