Summary -

In this topic, we described about the below sections -

Style attribute can be used to set the style in HTML elements. And also, can be used to apply a style to a single element. The styles applied by style attribute are local to the HTML documents where it coded.

Syntax -

<tagname style="CSS property:CSS value;">

Let us discuss some properties setting with Style attribute.

HTML Background Color

The background color property used to set the background of HTML element.

Example -

<!DOCTYPE html>
<html>
<head>
	<title>background color property example</title>
</head>
<body>
	<p style="background-color:green;"> text with green background</p>
</body>
</html>

Output -

text with green background

HTML Font Family

The font family property used to set how the font should display in HTML element.

Example -

<!DOCTYPE html>
<html>
	<head>
		<title>font family property example</title>
	</head>
	<body>
		<p style="font-family:verdana;"> Verdana font family text</p>
	</body>
</html>

Output -

Verdana font family text

HTML Text Align

The text align property used to set text horizontal alignment in HTML element.

Example -

<!DOCTYPE html>
<html>
	<head>
		<title>Text align property example</title>
	</head>
	<body>
		<p style="text-align:center;"> Center aligned text</p>
	</body>
</html>

Output -

Center aligned text

HTML Text color

The text color property used to set text color in HTML element.

Example:

<!DOCTYPE html>
<html>
	<head>
		<title>Text color property example</title>
	</head>
	<body>
		<p style="color:green;"> Green colored text</p>
	</body>
</html>

Output -

Green colored text