web设置字体样式
时间: 2023-08-29 09:04:28 浏览: 332
要设置网页中的字体样式,可以使用CSS样式表来实现。以下是一个简单的示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>网页标题</title>
<style type="text/css">
body {
font-family: Arial, sans-serif; /* 设置默认字体 */
font-size: 16px; /* 设置默认字体大小 */
}
h1 {
font-size: 24px; /* 设置标题字体大小 */
font-weight: bold; /* 设置标题加粗 */
font-style: italic; /* 设置标题斜体 */
color: #333; /* 设置标题颜色 */
}
p {
font-size: 18px; /* 设置段落字体大小 */
line-height: 1.5; /* 设置行高 */
color: #666; /* 设置段落颜色 */
}
</style>
</head>
<body>
<h1>网页标题</h1>
<p>这是一段示例文字。Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec euismod mollis justo, eu accumsan lectus molestie sed. In hac habitasse platea dictumst. Etiam bibendum tellus nec semper commodo. Sed ut eros eget libero convallis fringilla. Suspendisse potenti. Nullam et ex velit. Aliquam erat volutpat. In suscipit mauris nec massa dictum, eget feugiat ipsum molestie. Nulla facilisi. Fusce eget semper nisl, sed pellentesque libero.</p>
</body>
</html>
```
在上面的示例中,`body` 元素用于设置网页的默认字体和字体大小。`h1` 和 `p` 元素则用于设置标题和段落的字体样式。其中,`font-size` 属性用于设置字体大小,`font-weight` 属性用于设置字体加粗,`font-style` 属性用于设置字体斜体,`color` 属性用于设置字体颜色,`line-height` 属性用于设置行高。你可以根据自己的需求进行调整。