The HTML Style Attribute
The HTML style attribute is used to add styles to an element, such as color, font, size, and more. This is known as Inline CSS.
Basic Syntax
<tagname style="property:value;">Common Styling Properties
Background Color
The background-color property defines the background color for an HTML element.
<body style="background-color:powderblue;"> <h1 style="background-color:tomato;">This is a heading</h1>
Text Color
The color property defines the text color for an HTML element.
<h1 style="color:blue;">This is a blue heading</h1> <p style="color:red;">This is a red paragraph.</p>
Fonts and Sizes
Use font-family for fonts and font-size for text size.
<h1 style="font-family:verdana;">This is a heading</h1> <p style="font-size:300%;">This is a paragraph.</p>
Text Alignment
The text-align property defines the horizontal text alignment for an HTML element.
<h1 style="text-align:center;">Centered Heading</h1>