Home>Article>Web Front-end> What are the methods to set the background color of DIV?

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

php中世界最好的语言
php中世界最好的语言 Original
2017-11-21 11:48:24 14159browse

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

背景为黑色

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 aobjectThe 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源代码: 
背景色为红色

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 otherupdates 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!

Statement:
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
Previous article:How to use DIV+CSS Next article:How to use DIV+CSS