HTML Styles

What is Style?

The style attribute is used to add CSS directly to HTML elements.

Example

<p style="color:red;">This text is red</p>

<p style="font-size:22px;">Big text paragraph</p>

<h1 style="color:blue; text-align:center;">
    Center Blue Heading
</h1>
Try it Yourself

color

Text color

font-size

Text size

text-align

Text alignment

Summary

  • Style adds CSS to HTML
  • Used for colors, fonts, layout
  • Can be applied inline