Home >Web Front-end >Front-end Q&A >How to change the background color with css

How to change the background color with css

藏色散人
藏色散人Original
2021-04-25 09:23:469014browse

How to change the background color in css: 1. Set the background color directly in the p tag, with code such as "86e59c05fdf6760c089735784e0f4635"; 2. Set the p background color through external css, Code such as ".pcss5{ background:#F00; color:#FFF}".

How to change the background color with css

The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.

How to set the background color of div with css

1. Set the background color directly in the p tag

The code is as follows:

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

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

Set the background color in the p tag Screenshot

Set the background color by setting style in the p tag Wait for the CSS style.

2. Set the p background color with external css

Here, the CSS name for an object is ".pcss5", and set the background color of the p object by creating an external selector

CSS code:

The code is as follows:

.pcss5{ background:#F00; color:#FFF}

html source code:

The code is as follows:

<div class="divcss5">背景色为红色</div>

Effect screenshots:

External CSS setting p background color screenshots

[Recommended learning: css video tutorial]

The above is the detailed content of How to change the background color with css. 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