What are the methods to set the background color of DIV?

php中世界最好的语言
Release: 2017-11-21 11:48:24
Original
14264 people have browsed it

There are two ways to set the background color of a DIV. One is to set the background color directly within the div tag, and the other is to set the div background color using external CSS. Today I will explain these two methods in detail.

1. Set the background color directly in the div tag

<div style="background:#000; color:#FFF">背景为黑色</div>
Copy after login

Set the background color in the DIV tag to black and the font color to white

Setting the background color of div

Screenshot of setting the background color in the div tag

Set the background color and other CSS styles by setting the style in the div tag.

2. Set the div background color with external css

Here is a objectThe CSS is named ".divcss5", and the background color of the DIV object is set by creating an external selector

CSS code:

.divcss5{ background:#F00; color:#FFF} 
html源代码:
<div class="divcss5">背景色为红色</div>
Copy after login

These are the two ways to set the background color of DIV. Friends in need can save it. Please also continue to pay attention to other updates on this site .

Related reading:

How to use DIV+CSS


What is CSS


Commonly used link tag annotations in HTML

The above is the detailed content of What are the methods to set the background color of DIV?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template