Advertisement
❮ Previous: HTML Paragraphs Next: HTML Text Formatting ❯

HTML Styles

The HTML style attribute is used to add styles to an element.

Example

<p style="color: red">This is a paragraph</p>

<p style="background-color: red">This is a paragraph</p>

<p style="font-family: monaco">This is a paragraph</p>

Try this code ❯


The HTML Style Attribute Syntax

The HTML style attribute has the following syntax:

<tagName style="property:value;">

Text Color

The CSS color property sets the color for an HTML element.

Example

<p style="color: red">This is a paragraph</p>

Try this code ❯


Background Color

The CSS background-color property sets the background color for an HTML element.

Example

<p style="background-color: red">This is a paragraph</p>

Try this code ❯


Fonts

The CSS font-family property sets the fonts for an HTML element.

Example

<p style="font-family: monaco">This is a paragraph</p>

Try this code ❯


Text Size

The CSS font-size property sets the text size for an HTML element.

Example

<p style="font-size: 100px">This is a paragraph</p>

Try this code ❯


Advertisement

Text Alignment

The CSS text-align property sets the text alignment for an HTML element.

Example

<p style="text-align: right">This is a paragraph</p>

Try this code ❯


Border and Border Radius

The CSS border and border-radius property sets the border and border radius for an HTML element.

Example

<p style="border: 1px solid black">This is a paragraph</p>

<p style="border: 1px solid black;border-radius: 5px;">This is a paragraph</p>

Try this code ❯


A complete list of all HTML tags, see HTML Tag Reference.

A complete list of all attributes for each HTML element: See HTML Attribute Reference.

❮ Previous: HTML Paragraphs Next: HTML Text Formatting ❯
Advertisement