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

[html]<div>[/html]

tags. First, we have to add style attributes to each of our opening

[html]<div>[/html]

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:

[css] <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>[/css]

Sample output of above code:

 

Hello World.

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.


Related Posts:

Building a web page with HTML tags

MORE CSS PROPERTIES

Build to-do list web-app with code

Paginate Your WordPress Site Without Plugins

Redirect New Registered Users to a Specific Page – WordPress

The HTML paragraph tag: p and /p

What is a Blog?

The color CSS property

Crackin’ the code: Declo students learn computer programming

Introduction to Python Programming Language

WordPress Posts vs Pages

How do I create money online using WordPress?

Change the Author Permalink Structure – WordPress

Our Downloads Section

How To Start a Blog – Beginner’s Guide for 2018

CODING WITH CSS: The style attribute

How do I start a WordPress blog? (hosting wordpress)

Methods of teaching programming

Object-Oriented Programming (OOP)

 

Connected through code, Choose Your Platform!

About the Author: Bernard Aybout

In the land of bytes and bits, a father of three sits,With a heart for tech and coding kits, in IT he never quits.At Magna's door, he took his stance, in Canada's wide expanse,At Karmax Heavy Stamping - Cosma's dance, he gave his career a chance.With a passion deep for teaching code, to the young minds he showed,The path where digital seeds are sowed, in critical thinking mode.But alas, not all was bright and fair, at Magna's lair, oh despair,Harassment, intimidation, a chilling air, made the workplace hard to bear.Management's maze and morale's dip, made our hero's spirit flip,In a demoralizing grip, his well-being began to slip. So he bid adieu to Magna's scene, from the division not so serene,Yet in tech, his interest keen, continues to inspire and convene.