agyanadda@gmail.com

CSS Text

Styling Elements 1 min read Updated Dec 1, 2026 Topic 11 of 39

Text properties control how text is laid out.

Property Example values
text-align left, center, right, justify
text-decoration none, underline, line-through
text-transform uppercase, lowercase, capitalize
line-height 1.6
letter-spacing 2px
word-spacing 6px
text-indent 30px
text-shadow 2px 2px 4px gray

A line-height of about 1.5–1.7 makes paragraphs easy to read.

Example

Example — Text properties HTML
<style>
  h2 { text-align: center; text-transform: uppercase; letter-spacing: 3px; }
  .shadow { text-shadow: 2px 2px 4px #999; font-size: 24px; }
  .through { text-decoration: line-through; color: gray; }
  p { line-height: 1.7; }
</style>

<h2>Text styling</h2>
<p class="shadow">Text with a shadow</p>
<p class="through">Old price: ₹999</p>
<p>A comfortable line height makes long paragraphs much easier to read on any screen.</p>

Test Yourself With Exercises

Exercise 1 Multiple Choice

Which property removes the underline from links?

Exercise 2 Fill in the Blank

text-transform: ___; makes all letters capital.

Exercise 3 True / False

text-align: center; centres text horizontally.

Frequently Asked Questions

text-align only works horizontally. For vertical centring use Flexbox: display: flex; align-items: center;.