Home > Web Front-end > CSS Tutorial > Introduction to how to set div background color using css

Introduction to how to set div background color using css

高洛峰
Release: 2017-03-14 16:11:54
Original
2045 people have browsed it

This article mainly introduces the method of setting p background color with css. Friends who need it can refer to it

1. Set the background color directly in the p tag

The code is as follows:

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

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

Introduction to how to set div background color using css

Set the background color in the p tag screenshot

Set through the p tag style sets the background color and other CSS styles.

2. Set the p background color with external css

Here is a objectThe CSS is named ".pcss5", and the background color of the p object is set 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:

<p class="pcss5">背景色为红色</p>
Copy after login

Effect screenshot:

Introduction to how to set div background color using css

External CSS setting p background color screenshot

The above is the detailed content of Introduction to how to set div background color using 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