>

Background Colors in HTML and CSS

Overview

Setting the background color of a web page is a fundamental aspect of web design. This article provides a comprehensive guide to using HTML and CSS to control the background color and customize the visual appearance of your website.

CSS Method

In CSS, the background-color property is used to specify the background color. You can set it to any color value, including HTML color names, hexadecimal codes, and RGB values. Simply add the following line to your CSS stylesheet:

“`css body { background-color: #ff0000; } “`

HTML Method

In HTML, you can set the background color using the bgcolor attribute within the body tag. However, this method is deprecated and not recommended for modern web design practices. If you must use it, the syntax is as follows:

“`html “`

Leave a Reply