Để thiết lập màu nền bằng CSS, sử dụng thuộc tính background-color.
Ví dụ 1: Màu nền cho class
<!DOCTYPE html>
<html>
<head>
<style>
.demo {
text-decoration: overline underline;
background-color: red;
}
</style>
</head>
<body>
<h1>Chi tiết</h1>
<p class="demo">Trung tâm thi gần trường ABC College.</p>
<p class="demo2">Kỳ thi bắt đầu lúc 9AM.</p>
</body>
</html>
Kết quả

Ví dụ 2: Màu nền cho body (inline style)
<!DOCTYPE html>
<html>
<head>
<style>
.demo { text-decoration: overline underline; }
</style>
</head>
<body style="background-color: orange; color: white;">
<h1>Chi tiết</h1>
<p class="demo">Trung tâm thi gần trường ABC College.</p>
<p class="demo2">Kỳ thi bắt đầu lúc 9AM.</p>
</body>
</html>
Kết quả

Giá trị màu hợp lệ:
- Tên màu:
red,blue,orange... - Hex:
#ff0000,#f00 - RGB:
rgb(255,0,0) - RGBA:
rgba(255,0,0,0.5) - HSL:
hsl(0,100%,50%) - HSLA:
hsla(0,100%,50%,0.5) transparent: Trong suốt