<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div {
color: red;
font-size: 30px;
font-weight: bolder;
font-family: 楷体;
font-style: italic;
}
</style>
</head>
<body>
<div>大家好,我是《平凡的世界》的作者,路遥!</div>
</body>
</html>
color: red;—————设置字体颜色
font-size: 30px;———设置字体大小
font-weight: bolder;—设置字体粗细
font-family: 楷体;——-设置字体
font-style: italic;———设置是否倾斜
上边的方法写着太麻烦,可以使用字体属性连写替换。
<style>
div {
color: red;
font:italic bold 30px 微软雅黑;
}
</style>
font:font-style font-weight font-size font-family
其中,font-size和font-family是必须的。