css-结合方式

 1 <!DOCTYPE html>
 2 <html>
 3   <head>
 4     <title>01-结合方式.html</title>
 5     
 6     <meta name="keywords" content="keyword1,keyword2,keyword3">
 7     <meta name="description" content="this is my page">
 8     <meta name="content-type" content="text/html; charset=UTF-8">
 9     
10     <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
11     <!-- 
12             结合方式1:在标签上添加style属性,属性的值填写css代码。(所有标签上都有style属性)
13             结合方式2:使用head标签中的style标签来设置样式。
14             结合方式3:使用外部文件链接。
15      -->
16      
17          <link rel="stylesheet" type="text/css" href="./p.css">
18   <!-- 
19   <style type="text/css">
20                  p{
21                      color:blue;
22                      }
23      </style> 
24      -->
25 
26   </head>
27   
28   <body>
29     This is my HTML page. <br>
30     <p style="color:red;">My name is mujin.</p>
31     <p >My name is mujin.</p>
32   </body>
33 </html>

外部css文件:

1 p{
2     color:yellow;
3 }

总结:

共有三种方式:其中,第一种在标签内部添加css属性的优先级最高。内部样式表的优先级次之。外部链接样式表的优先级再次之。

posted @ 2016-08-29 12:59  ALMOST_MUJIN  阅读(130)  评论(0编辑  收藏  举报