How to change the background color of an element in CSS
To change the background color of an HTML element is easy using the css background-color property.
Suppose, you have an <div> element.
<div>I am a div element.</div>
Then, we can change the background color of that <div> using the following method.
Example 1 :
Using the inline styles...
<div style="background-color:red">I am a div element.</div>
Example 2 :
Using the Internal Styles...
<style> div{ background-color:red; } </style> <div style="background-color:red"> I am a div element. </div>
Example 3 :
Using the id attribute. First, we need to include the id attribute inside the div element.
<style> #my-id{ color:red ; background-color:black;} </style> <div id="my-id">This is a div element.</div>
save
listen
AI Answer
How to change the background color of an element in CSS
0
To change the background color of an HTML element is easy using the css background-color …
asked
Apu
0 answers
2915
To change the background color of an HTML element is easy using the css background-color …
Answer Link
answered
Apu