HTML Styles

The HTML style attribute is used to add styles to an element, such as color, font, size, and more.
Example
<!DOCTYPE html>
<html>
<body>
<h2>The style Attribute</h2>
<p>The style attribute is used to add styles to an element, such as color, font, size:</p>
<p style="color:red;">This is a red paragraph.</p>
<p style="font-size:50px">hii</p>
</body>
</html>
A new webpage opens as shown below:

Background Color
The CSS background-color property defines the background color for an HTML element.
Example
Set the background color for a page to yellow:
<!DOCTYPE html>
<html>
<body style="background-color:yellow;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>

Example
Setting background color for two different elements:
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:hsl(186, 41%, 48%);">This is a heading</h1>
<p style="background-color:hsl(129, 100%, 64%);">This is a paragraph.</p>
</body>
</html>
A new webpage opens as shown below:

Text Color
The CSS color property defines the text color for an HTML element:
Example
<!DOCTYPE html>
<html>
<body>
<h1 style="color:hsl(337, 100%, 50%);">This is a heading</h1>
<p style="color:hsl(212, 100%, 50%);">This is a paragraph.</p>
</body>
</html>
The text color is set according to the colors that have been chosen.

No comments:
Post a Comment