在开发网页时,我们通常需要使用外部字体来美化网页样式或实现特殊的排版需求。CSS提供了一种简单的方法来引入外部字体,本文将为大家介绍如何在CSS中引入外部字体。 本文中将使用Google Fonts为...
在开发网页时,我们通常需要使用外部字体来美化网页样式或实现特殊的排版需求。CSS提供了一种简单的方法来引入外部字体,本文将为大家介绍如何在CSS中引入外部字体。
本文中将使用Google Fonts为例,演示如何引入一种名为Lato的外部字体。
首先,我们需要在标签中引入该字体的链接,代码如下:
<head>
<link href="https://fonts.googleapis.com/css?family=Lato&display=swap" rel="stylesheet">
</head>
p {
font-family: 'Lato', sans-serif;
}
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Lato&display=swap" rel="stylesheet">
</head>
<br>
<body>
<p>Hello World!</p>
</body>
<br>
<style>
p {
font-family: 'Lato', sans-serif;
}
</style>
</html>