Home > Article > Web Front-end > How to set the background color in html web page production
The methods for setting the background color of a web page in HTML are: Inline style: Set the background color in the style attribute of the HTML element. External style sheet: Define style rules in CSS files. CSS variables: Use CSS variables to set the background color. Image as background: Use the background-image attribute to specify an image as the background.
How to set the background color of HTML web pages
Method 1: Inline style
Set the background color in the style attribute of the HTML element. For example:
<body style="background-color: #ffffff;">
Method 2: External style sheet
Define style rules in an external style sheet (.css) file. For example:
<code class="css">body { background-color: #ffffff; }</code>
Method 3: CSS variables
Use CSS variables to set the background color. For example:
<code class="css">:root { --bg-color: #ffffff; } body { background-color: var(--bg-color); }</code>
Method 4: Image as background
Use the background-image
attribute to specify an image as the background. For example:
<body style="background-image: url('my_image.png');">
Other settings for background color Properties:
The above is the detailed content of How to set the background color in html web page production. For more information, please follow other related articles on the PHP Chinese website!