HTML Tutorials


Text

People will come to your website so they can read text that you write! You can customize the text on your site in several ways.

You can change the color of words on your site by specifying a class and using the color property like so: .blue-txt{ color: blue }. You can also align text to the right, center, or left using the text-align property. Both properties are demonstrated below. In this example we'll also show you how you can use multiple properties in one tag. The syntax looks like: <tag class="first-class second-class">Your text here!</tag>.



Code

<!DOCTYPE html>
<html>
  <head>
    <title>Text!</title>

    <style>
      .blue-txt{ color: blue }
      .red-txt{ color: red }
      .right-txt{ text-align: right }
      .center-txt{ text-align: center }
    </style>
  </head>

  <body>
    <p class="blue-txt">I'm blue! (If I was green I would die!)</p>
    <p class="red-txt">I'm red!</p>
    <p class="right-txt">I'm on the right!</p>
    <p class="center-txt blue-txt">I'm in the center and blue!</p>
  </body>
</html>

Result

I'm blue! (If I was green I would die!)

I'm red!

I'm on the right!

I'm in the center and blue!