Skip to content
Justice Tech School

Text Styling

color sets the text colour and text-align aligns it (left, right, center, justify). text-decoration adds or removes underline, overline and line-through. text-transform changes case: uppercase, lowercase or capitalize.

text-indent indents the first line, and text-decoration can take a colour and style too, for example underline wavy red.

Example
<style>
  h2 { text-align: center; text-transform: uppercase; color: #7c2d12; }
  .del { text-decoration: line-through; color: gray; }
  .wavy { text-decoration: underline wavy #dc2626; }
  .indent { text-indent: 30px; }
</style>
<h2>Centered heading</h2>
<p class="del">Old price</p>
<p class="wavy">Spelling mistake</p>
<p class="indent">The first line of this paragraph is indented.</p>

Exercise

Centre the heading text.

h1 {
  text-: center;
}

Quiz Test

Which value turns text into capital letters?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.