(1)内部
写到style标签中
<style type="text/css">
p {
color: blue;
background-color: yellow;
}
</style>
举例:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
<style type="text/css">
p {
color: blue;
background-color: yellow;
}
</style>
</head>
<body>
<p>落霞与孤鹜齐飞,秋水共长天一色</p>
</body>
</html>
(2)外部
写在外部的css文件中,然后通过link标签引入外部的css文件
<link rel="stylesheet" type="text/css" href="style.css" />
举例:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<p>落霞与孤鹜齐飞,秋水共长天一色</p>
</body>
</html>
style.css
p {
color: blue;
background-color: yellow;
}
总结:
这两种方式的效果是相同的,结果如下: