Skip to main content

HTML Styles | Enhance Web Design with HTML Style Attributes

The HTML style attribute is used to add styles to an element, such as color, font, size, and more.

As an example:

Editor

Loading...

HTML Style Attribute

Setting the style of an HTML element, can be done with the style attribute.

As an example:

The HTML style attribute has the following syntax.

<tagname style="property:value;"></tagname>

Where:

  • The tagname refers to the HTML element being styled, such as a div, p, h1, or any other valid HTML element.
  • The style attribute is used to apply CSS styles to the element.
  • The property refers to the specific CSS property being applied, such as background-color, font-size, padding, or any other valid CSS property.
  • The value refers to the value assigned to that CSS property, such as "red" for the "color" property or "20px" for the "font-size" property.

Background Color

The background-color specifies the background color of an element.

As an example:

Editor

Loading...

Text Color

The color specifies the color of the text.

As an example:

Editor

Loading...

Fonts

The font-family specifies the font family of the text.

As an example:

Editor

Loading...

Font Size

The font-size specifies the size of the text.

As an example:

Editor

Loading...

Text styles

The text-align specifies the alignment of the text.

As an example:

Editor

Loading...