目录
1、行内样式
<p style="color:red; font-size:18px;">我的字体颜色为红色,大小为18像素</p>
2、内部样式表
<head>
<style type="text/css">
p
{
color: red;
font-size: 18px;
}
</style>
</head>
<body>
<p>我的字体颜色是红色,大小为18像素。</p>
</body>
3、外部样式表
(1)链接式
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<p>我的字体颜色是红色,大小为18像素</p>
</body>
(2)导入式
<head>
<style type="text/css">
@import url("css/style.css");
</style>
</head>
<body>
<p>我的字体颜色是红色,大小为18像素</p>
</body>
※:导入式也可以用在CSS文件导入外部CSS文件,如下面的style1.css导入外部style2.css:
@import url("css/style2.css");
p
{
color:red;
font-size: 18px;
}