使用 CSS 设置单词间距

cssweb developmentfront end technology更新于 2024/11/20 2:52:17

要设置单词之间的间距,请使用 word-spacing 属性。属性值如下 −

word-spacing: normal|length|initial|inherit;

示例

现在来看一个例子 −

<!DOCTYPE html>
<html>
<head>
<style>
p.demo1 {
   word-spacing: normal;
}
p.demo2 {
   word-spacing: 10px;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<h2>Heading2</h2>
<p class="demo1">This is demo text.</p>
<h2>Heading2</h2>
<p class="demo2">This is demo text.</p>
</body>
</html>

输出

示例

现在让我们看另一个例子 −

<!DOCTYPE html>
<html>
<head>
<style>
p.demo1 {
   word-spacing: 3cm;
}
p.demo2 {
   word-spacing: 40px;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<h2>Heading2</h2>
<p class="demo1">This is demo text.</p>
<h2>Heading2</h2>
<p class="demo2">This is demo text.</p>
</body>
</html>

输出


相关文章


有用资源