Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Have you ever wondered how websites remove the default blue underline from navigation links, make badge titles display in crisp ALL-CAPS without retyping them in HTML, or align paragraph edges neatly like a printed newspaper? 📰
In CSS, text layout is refined using properties that control:
text-align)text-decoration)text-transform)letter-spacing, word-spacing)Let us explore these powerful properties through the lens of a school magazine editor!
Imagine you are the chief student editor of your school's Annual Magazine:
+-------------------------------------------------------------------------+ | THE MAGAZINE EDITOR'S TOOLBOX | +-------------------------------------------------------------------------+ | 1. text-align: center --> Centering the Principal's message headline| | 2. text-align: justify --> Aligning both left & right edges of essays| | neatly like a newspaper column | | 3. text-decoration: none --> Removing ugly underlines from navigation | | 4. text-decoration: --> Striking through old ticket prices | | line-through (Annual Day Pass: ~Rs. 100~ Free!) | | 5. text-transform: --> Forcing badges to ALL-CAPS without typing | | uppercase every letter in caps manually in HTML | | 6. letter-spacing: 2px --> Adding breathing room between capital | | letters for a luxury title feel | +-------------------------------------------------------------------------+
text-align (Horizontal Alignment)Controls how text is positioned horizontally within its container.
text-decoration (Lines and Underlines)By default, every web browser automatically draws an underline under <a> link tags. One of the very first things frontend developers do is remove or customize that underline!
none ⭐):none: Removes all underlines or lines.underline: Draws a line directly below the text.line-through: Draws a line through the middle (perfect for e-commerce discounts: ~₹999~ ₹499).overline: Draws a line above the text.In modern CSS, you can even customize the color and wavy style of the line:
text-transform (Smart Capitalization)Why is text-transform a lifesaver? Imagine you have 100 buttons that need to display in uppercase. Instead of manually typing <button>SUBMIT APPLICATION</button> in HTML, you simply write normal sentence case in HTML and let CSS do the transformation!
letter-spacing and word-spacingThese properties adjust the micro-spacing between letters and words:
letter-spacing (Tracking)Expands or contracts the space between individual letters. It is widely used by UI designers on uppercase headers and small badges to give them a premium, airy aesthetic:
word-spacingControls the spacing between entire words:
text-indent (First-Line Indentation)In printed storybooks and textbooks, the very first line of a new paragraph is often pushed inward by a few centimeters. In CSS, you achieve this using text-indent:
| What Beginners Do (Don't ❌) | What You Should Do Instead (Do ✅) | Why? |
|---|---|---|
Typing all caps directly in HTML (<h1>ADMISSIONS</h1>). | Use text-transform: uppercase;. | Keeping HTML in natural sentence case helps screen readers pronounce words correctly instead of spelling them out as abbreviations! |
Using text-align: center on inline tags like <span>. | Apply text-align to the parent block element (like <p> or <div>). | Inline elements have no outer width to center within. |
Forgetting text-decoration: none on button links. | Add text-decoration: none; to navigation <a> tags. | Without it, link buttons will show an unsightly underline across the button text. |
text-align sets horizontal alignment: left, center, right, or justify.text-decoration: none removes the default browser underline from links.text-decoration: line-through strikes through text (ideal for discounted prices).text-transform: uppercase converts text to capital letters cleanly through CSS.letter-spacing adds breathing room between individual characters for refined titles.Test your understanding with these multiple-choice questions:
<a> link?text-transform: capitalize; to the phrase "science and technology"?text-align adjusts the spacing between words so that text aligns flush with both the left and right margins, like a printed newspaper?magazine-badge.html.text-transform, letter-spacing, line-through, and text-decoration: none create a stunning, polished layout! 🎯In the next lesson, we will continue your web styling journey with Absolute Units: Pixels (px), Points (pt) (CSS Units and Measurements).
👉 Continue to Next Lesson: Absolute Units: Pixels (px), Points (pt) →
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Font Size, Weight, Style, and Line Height | Absolute Units: Pixels (px), Points (pt) |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.