content: normal | none | counter | string | attr | open-quote | close-quote | no-close-quote | no-open-quote | url | initial | inherit;
值 | 说明 |
normal | 用于设置默认值 |
none | 此值不会设置内容。 |
counter | 它将内容设置为计数器。通常是一个数字。使用 counter()或 counters()函数显示。 |
string | 它用于设置任何字符串值。它应始终用引号引起来。它会在HTML元素之后或之前生成任何字符串。 |
attr | 它将在元素之后或之前插入指定属性的值。如果选择器没有特定属性,则将插入一个空字符串。 |
open-quote | 用于插入引号,或将内容设置为引号。 |
close-quote | 用于插入右引号,或将内容设置为右引号。 |
no-close-quote | 如果指定了右引号,则用于从内容中删除右引号。 |
no-open-quote | 如果指定了开头引号,则用于从内容中删除开头引号。 |
url | 它用于将内容设置为某些媒体,可以是图像,视频,音频等等。 |
initial | 用于将属性设置为其默认值。 |
inherit | 它从其父元素继承属性。 |
<!DOCTYPE html>
<html>
<head>
<title>
CSS content Property
</title>
<style>
body {
text-align: center;
}
p {
font-size: 25px;
}
p::before {
content: "Welcome ";
}
#para::before {
content: normal;
}
#para1::before {
content: none;
}
</style>
</head>
<body>
<h1> CSS content property </h1>
<h2> Use of content: normal; and content: none; </h2>
<p> to the bianchenghao6.com </p>
<p id="para"> This is a paragraph using <b>normal</b> value. </p>
<p id="para1"> This is another paragraph using <b>none</b> value. </p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>
CSS content Property
</title>
<style>
body {
text-align: center;
}
p {
font-size: 25px;
}
p::before {
content: "Hello World. Welcome ";
}
#para::before {
content: url("https://bianchenghao6.com/images/icon3.png");
}
#para1::before {
content: url("https://bianchenghao6.com/images/icon3.png");
}
</style>
</head>
<body>
<h1> CSS content property </h1>
<h2> Use of content: string; and content: url(); </h2>
<p> to the bianchenghao6.com </p>
<p id="para"> This is a paragraph using the <b>url()</b> value. </p>
<p id="para1"> This is another paragraph using the <b>url()</b> value. </p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>
CSS content Property
</title>
<style>
body {
text-align: center;
}
p {
font-size: 25px;
}
p::before {
content: open-quote;
}
p::after {
content: close-quote;
}
</style>
</head>
<body>
<h1> CSS content property </h1>
<h2> Use of content: open-quote; and content: close-quote; </h2>
<p> Welcome to the bianchenghao6.com </p>
<p> This is another paragraph. </p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
body {
text-align: center;
}
p {
font-size: 25px;
}
p::before {
content: open-quote;
}
p::after {
content: close-quote;
}
p.para::before {
content: no-open-quote;
}
p.para::after {
content: no-close-quote;
}
</style>
</head>
<body>
<h1> CSS content property </h1>
<h2> Use of content: no-open-quote; and content: no-close-quote; </h2>
<p> Welcome to the bianchenghao6.com </p>
<p class="para"> This is another paragraph </p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>
CSS content Property
</title>
<style>
body {
text-align: center;
}
a::after {
content: attr(href);
}
</style>
</head>
<body>
<h1> CSS Content property </h1>
<h2> The following link is displayed by using the <b>attr()</b> </h2>
<a href=https://bianchenghao6.com>Click here! </a>
</body>
</html>