Home HTML CSS JavaScript React Gamedatum.com
× Home HTML CSS JavaScript React Gamedatum.com

Styles


HTML provides the option to style your elements adding color, changing the size, the alignment or the font of a text and much more. The way to do this is by using this attribute: style.

Let's use the style attribute:

               
                
    <!-- add color -->
  <p style="color:red;">This is a paragraph in red color.</p>
  <p style="color:green;">This is a paragraph in green color.</p>
  <p style="color:blue;">This is a paragraph in blue color.</p>
                
                
              

The result:

This is a paragraph in red color.

This is a paragraph in green color.

This is a paragraph in blue color.

Let's change the size of the sentence below:

               
                
    <!-- change the font size-->
  <h1>This is a heading</h1>
  <h1 style="font-size: 15px;">This is the same heading with a changed size</h1>
                
                
              

The result:

This is a heading

This is the same heading with a changed size

You can also change the font of the text:

               
                
    <!-- text aligned to the center-->
  <p style="text-align:center;">This is some centered text </p>
                
                
              

The result:

This is some centered text