第三课--插入样式表

165 阅读1分钟
插入样式表的方法有三种:
外部样式表(External style sheet):<link rel="stylesheet" href="demo.css">
内部样式表(Internal style sheet):<style></style>
内联样式(Inline style):<p style="color:yellow;"></p>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- 外部样式 style.css -->
    <link rel="stylesheet" type="text/css" href="demo.css"/>
    <!-- 设置:h3{color:blue;} -->
    <style type="text/css">
      /* 内部样式 */
      h3{color:green;}
    </style>
</head>
<body>
    <h3>测试!</h3>
</body>
</html>
优先级:
<head>
    <!-- 外部样式 style.css -->
    <link rel="stylesheet" type="text/css" href="style.css"/>
    <!-- 设置:h3{color:blue;} -->
    <style type="text/css">
      /* 内部样式 */
      h3{color:green;}
    </style>
</head>
<body>
    <h3>测试!</h3>
</body>