In the example below, the <h1>, <p>, and <div> elements have different background colors.
Html Code:
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
background-color: green;
}
div {
background-color: lightblue;
}
p {
background-color: yellow;
}
</style>
</head>
<body>
<h1>CSS background-color example!</h1>
<div>
This is a text inside a div element.
<p>This paragraph has its own background color.</p>
We are still in the div element.
</div>
</body>
</html>
Html Code Result:
CSS background-color example!
This is a text inside a div element.
This paragraph has its own background color.
We are still in the div element.
This is a text inside a div element.
This paragraph has its own background color.
We are still in the div element.
Post a Comment