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

What is the usage of before in css

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-04-25 18:14:4914698browse

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>

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!

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