style attribute
HTML elements can be styled in three ways. Namely:
- Inline style
- Internal style
- External style
styleHTML attributes are used for inline styling . styleAll CSS properties can be used in attributes.
Syntax
content
Set the color of text using the style attribute
colorThe text of an HTML element is colored through properties.
Examples
HTML style attributes
The color of this paragraph has been changed to teal using the style attribute.
Output
The color of this paragraph has been changed to teal using the style attribute.
Set background color using style attribute
background-colorThe background color of an HTML element is set through a property.
Examples
HTML style attribute
Table of Contents
Toggle
This is Heading
This is a paragraph.
Output
This is Heading
This is a paragraph.
Setting the font using the style attribute
font-familyThe font of an HTML element is set through properties.
Examples
HTML style attribute
This is a paragraph.
This is a paragraph.
Output
This is a paragraph.
This is a paragraph.
Set text size using style attribute
font-sizeThe text size of an HTML element is determined through properties.
Examples
HTML style attributes
This is a paragraph.
This is a paragraph.
Output
This is a paragraph.
This is a paragraph.
Set text alignment using the style attribute
text-alignThe position of the content of an HTML element is determined through properties.
Examples
HTML style attributes
This paragraph will be centered.
This paragraph will be right.
Output
This paragraph will be centered.
This paragraph will be right.
Chapter summary
styleAttributes are used to style HTML elements inline .colorProperties are used to set the color of the text .background-colorThe property is used to set the background color .font-familyProperties are used to set the font of text .font-sizeProperties are used to determine the size of the text .text-alignUsed to determine the location of content .


