Set the backgro...LOGIN

Set the background color of different elements

This example demonstrates:

Set different background colors for h1, p, and div elements respectively.

Example analysis:

h1{background-color :#6495ed;}

p{background-color:#e0ffff; }

div{background-color:#b0c4de;}

Use the element selectors h1{}, p{}, and div{} to select the h1, p, and div elements in HTML respectively, and then use the background-color attribute in {} to set the background color


Next Section
1
2
<!DOCTYPE html>
<html>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
submitReset Code
ChapterCourseware