The background-color CSS property: Now you understand more about CSS and how it works, let’s see how we can use CSS properties to make our page more colourful.
Web pages need to look eye-catching and interesting. We can change the background colour of different areas of our page using different
tags. First, we have to add style attributes to each of our opening
tags. Then inside the style attribute we set the background-color CSS property and choose a colour for the CSS value. The code we need looks like this:
<body> <p>Hello World.</p> <div style="background-color: green;"> <!--background-color property--> <p>This is my page.<br/> My very first webpage</p> </div> <div style="background-color: cyan;"> <p>Changing colors is easy<br/> once you know the right HTML/CSS tags.</p> </div> </body>
Sample output of above code:
This is my page.
My very first webpage
Changing colors is easy
once you know the right HTML/CSS tags.
There are thousands of colours that you can use as values in CSS. Go to Visit W3Schools to view more of them.