How to change the background color with css

藏色散人
Release: 2023-01-05 16:11:05
Original
8904 people have browsed it

How to change the background color in css: 1. Set the background color directly in the p tag, with code such as "

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>
Copy after login

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}
Copy after login

html source code:

The code is as follows:

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

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!

Related labels:
css
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!