css如何设置字体

css设置字体的方法:1、使用font标签进行设置,语法格式为“”;2、使用font-family属性进行设置,语法格式为“标签{font-family:“字体样式”}”

css如何设置字体

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

一、font标签配置字体

<font face="字体样式"></font>

例子:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>未设置字体的“你若盛开,蝴蝶自来”</div>
  <font face="华文中宋">设置字体的“你若盛开,蝴蝶自来”</font>
</body>
</html>

font标签设置face字体属性其值即可设置差别字体

二、css设置字体

css字体设置单词为font-family

例子:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    p{
      font-family: &#39;Courier New&#39;, Courier, monospace;
    }
  </style>
</head>
<body>
  <p>设置字体的“你若盛开,蝴蝶自来”</p>
  <div>未设置字体的“百无禁忌”</div>
</body>
</html>

效果:

PVIY{X@4T9OHZT$APFGCP8V.png

推荐学习:css视频教程

以上就是css如何设置字体的详细内容,更多请关注https://www.sxiaw.com/其它相关文章!