HTML CSS JavaScript SEO Python Posts Privacy About Contact

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

PropertyWhat it doesExample
colorChanges text colorcolor: red
background-colorChanges background colorbackground-color: yellow
font-familyChanges the fontfont-family: Arial
font-sizeChanges text sizefont-size: 20px
text-alignAligns texttext-align: center

Note: Inline styles (using the style attribute directly on a tag) are great for quick tests. For larger projects, use a separate CSS file for better organisation.