Home > Web Front-end > CSS Tutorial > What is the usage of before in css

What is the usage of before in css

醉折花枝作酒筹
Release: 2023-01-05 16:11:15
Original
14747 people have browsed it

In CSS, the usage of before is to insert new content before the element content. You only need to set "element:before{attribute:attribute value;}" to the element. The ":before" selector must use the content attribute to specify the content to be inserted.

What is the usage of before in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

Definition and usage

:The before selector inserts content before the content of the selected element.

Please use the content attribute to specify the content to be inserted.

Example:

<!DOCTYPE html>
<html>
<head>
<style>
p:before
{
content:"台词:";
background-color:yellow;
color:red;
font-weight:bold;
}
</style>
</head>

<body>

<p>我是唐老鸭。</p>
<p>我住在 Duckburg。</p>

</body>
</html>
Copy after login

Run result:

What is the usage of before in css

Recommended learning:css video tutorial

The above is the detailed content of What is the usage of before in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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