The HTML Styles style attribute is used to add styles to an element, such as color, font, size, and more.
Example
I am Red
I am Blue
I am Black
The HTML Style Attribute
The style attribute can be used to set an HTML element’s style.
The syntax for the HTML style attribute is as follows:
Background Color
An HTML element’s background color is specified using the CSS background-color attribute.
Example
Set the background color for a page to red:
This is a title
This is a sentence.
Example
Set background color for two different elements:
This is a title
This is a sentence.
Text Color
The text color of an HTML element is specified by the CSS color property:
Example
This is a title
This is a sentence.
Fonts
The font that will be used for an HTML element is specified using the CSS font-family property:
Example
This is a title
This is a sentence.
Text Size
The text size of an HTML element is specified via the CSS font-size property:
Example
This is a title
This is a sentence.
Text Alignment
An HTML element’s horizontal text alignment is specified using the CSS text-align property:
Example
Centered Title
Centered sentence.
HTML
HTML5
HTML tutorials
Learn HTML
Free HTML tutorials
HTML Example
HTML Explained
HTML style attribute
HTML styles attribute tag
inline CSS
background-color
color
font-family
font-size
text-align
HTML provides a variety of ways to style web content, from inline styles to external stylesheets. Understanding these styling options is crucial for creating visually appealing and well-structured web pages.
The HTML `style` (HTML Style Attribute tag)attribute allows you to apply CSS directly to an HTML element. This is known as inline CSS and can be used to set properties like `background-color`, `color`, `font-family`, `font-size`, and `text-align`.