text-shadow: adds a shadow, e.g. 2px 2px 4px #000.
💡 Key Takeaways: CSS Text
Mastering CSS Text helps you write clean and reliable CSS code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
CSS Text Code Example
CSS
<style>
.center { text-align: center; }
.upper { text-transform: uppercase; letter-spacing: 4px; }
.strike { text-decoration: line-through; color: #94A3B8; }
.shadow { font-size: 32px; color: #2563EB; text-shadow: 2px 2px 6px rgba(0,0,0,.3); }
.spaced { line-height: 2; text-indent: 40px; }
</style>
<p class="center">Centred text</p>
<p class="upper">uppercase with letter spacing</p>
<p class="strike">Crossed out</p>
<p class="shadow">Text shadow</p>
<p class="spaced">This paragraph has a large line height and an indented first line, which makes long text easier to read.</p>
Free sign-in required · Google login available
CSS Text Practice Exercises
Check what you learned in “CSS Text”.
/ 3 solved
Fill in the blank
Make the text uppercase.
h2 {
text-transform: ;
}
✓ Correct!Not quite. Try again.
Multiple choice
Which property removes the underline from links?
✓ Correct!Not quite. Try again.
Code challenge
Centre the heading text.
Write the code in the live editor. Your answer is checked automatically.