In this article we are going to explain what is style attribute in html or how to set style like color, background-color, text-align, font-family, font-size in html element with example.


HTML Style is used to change or add the style of HTML elements. There is a default style for every HTML element e.g. background color is white, text color is black etc.

The style attribute can by used with any HTML tag. To apply style on HTML tag, you should have the basic knowledge of css properties e.g. color, background-color, text-align, font-family, font-size etc.

You can easily edit background color, text size, text color and text alignment of any document using HTML text style tags.

HTML text style tags use the following syntax:

 <tag name e.g. p, div etc.  style = “property:value;”

The syntax of style attribute is given below:


Let's see an example of HTML style attribute.

<!DOCTYPE html>
    <title>Example of style attribute </title>   
    <p style="background-color:yellow; color:blue; font-family:Verdana">
    This is a background color change example



I hope this article will help to you after reading.


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

you may also like