Home > Article > Web Front-end > How to change the background color with css
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}".
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!