HTML Styles
The HTML style attribute is used to add styles to an element, such as color, font, size, and more.
The HTML Style Attribute
The HTML style attribute is used to add styles to an element, such as color, font, size, and more.
Syntax: <tagname style="property: value;">
The property is a CSS property and the value is a CSS value.
Try It — All Style Types
Preview
Common Style Properties
| Property | What it does | Example |
|---|---|---|
color | Changes text color | color: red |
background-color | Changes background color | background-color: yellow |
font-family | Changes the font | font-family: Arial |
font-size | Changes text size | font-size: 20px |
text-align | Aligns text | text-align: center |
Note: Inline styles (using the
styleattribute directly on a tag) are great for quick tests. For larger projects, use a separate CSS file for better organisation.