How to set background color for a element in html     In html we can write css code to set th

How to set background color for a element in html     In html we can write css code to set the background color for a element. every
Generic placeholder image

Mukesh R

How to set background color for a element in html

    In html we can write css code to set the background color for a element. every element in the html has style attribute. inside this style attribute we can write css code
    
    Example  
<div style="background-color:red;">
background color will be red
</div>
we can use all css properties into this style tag.
    
    To see the demo open a notepad , copy the below code and save with some file name with extension ".html" , then open the file using a browser now you can see the background color for the body.
<!DOCTYPE html>
<html>
<body style="background-color:blue;">
<h1>The portion background color will be blue</h1>
<div style="background-color:red;">
The portion background color will be red
</div>

</body>
</html>