style Attribute in HTML

HTML element styling like color, font, size, etc can be done with the help of style attribute.
HTML style attribute has the following syntax:

<tagname style="property:value;">

where, property is a CSS property and value is a CSS value.


Background Color in HTML

background-color property denotes the background color for an HTML element.

Example


<html>
<body style="background-color:orange;">
<h3>Example of background-color </h3>
<p>
Community for developers.
</p>
</body>
</html>

Output

Example of background-color

Community for developers.


Text Color in HTML

color property denotes the text color for an HTML element.

Example


<html>
<body>
<h1 style="color:green;">
Example of Text Color
</h1>
<p style="color:red;">
Community for developers.
</p>
</body>
</html>

Output

Example of Text Color

Community for developers.


Fonts in HTML

font-family property denotes the font to be used for an HTML element.

Example


<html>
<body>
<h1 style="font-family:verdana;">
Example of Fonts
</h1>
<p style="font-family:arial;">
Community for developers.
</p> 
</body>
</html>

Output

Example of Fonts

Community for developers.


Text Size in HTML

font-size property denotes the size of text for an HTML element.

Example


<html>
<body>
<h1 style="font-size:250%;">
Example of Text Size 
</h1>
<p style="font-size:150%;">
Community for developers.
</p>
</body>
</html>

Output

Example of Text Size

Community for developers.


Text Alignment in HTML

text-align property denotes the horizontal text alignment for an HTML element.

Example


<html>
<body>
<h1 style="text-align:center;">
Example of Text Alignment
</h1>
<p style="text-align:center;">
Community for developers.
</p> 
</body>
</html>

Output

Example of Text Alignment

Community for developers.

Subscribe & Get Regular Updates On Your E-mail