Day38:css1
1:css method:css is better to put in a text.css
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Title</title> 6 <!--the second method of introduce css:--> 7 8 <!-- <style>--> 9 <!-- p{--> 10 <!-- color:rebeccapurple;--> 11 <!-- font-size: 40px;--> 12 <!-- }--> 13 <!-- a{--> 14 <!-- text-decoration:none;--> 15 <!-- }--> 16 <!-- </style>--> 17 18 <!-- ##############the best method: third meethod of introduce css: --> 19 <!-- <link rel="stylesheet" href="test1.css">--> 20 21 <!-- the fourth meethod of introduce css: --> 22 <style> 23 @import "test1.css"; 24 </style> 25 </head> 26 <body> 27 28 <!--the first introduce method:--> 29 <!--<div style="color: red;background-color: blue">hello chen</div>--> 30 31 <div>hello div</div> 32 <p>hello p</p> 33 <a href="">click me</a> 34 </body> 35 </html>
2:css selector:
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Title</title> 6 7 <style> 8 /**{*/ 9 /* color: red;*/ 10 /*}*/ 11 div{ 12 13 } 14 15 #littlep{ 16 background-color: yellow; 17 } 18 19 .bigp{ 20 color: crimson; 21 } 22 23 /*id is unique so it can be find just by # */ 24 /*p#littlep{*/ 25 /* background-color: cornflowerblue;*/ 26 /*}*/ 27 div.bigp{ 28 color: chocolate; 29 } 30 31 #littlep,div.bigp{ 32 color: darkgreen} 33 34 .div1 div{ 35 color: darkmagenta; 36 } 37 38 .div1 .div2{ 39 color: fuchsia; 40 } 41 42 .div1 +div{ 43 background-color: cyan; 44 } 45 [alex]{ 46 color: darkred; 47 } 48 /*[alex="dasb"]{*/ 49 /* color: cornflowerblue;*/ 50 /* font-size: 40px;*/ 51 /*}*/ 52 p[alex="dasb"]{ 53 color: cornflowerblue; 54 font-size: 40px; 55 } 56 57 [alex~="li"]{ 58 color: pink; 59 } 60 [alex^="l"]{ 61 color: blueviolet; 62 } 63 [alex*="l"]{ 64 color: blueviolet; 65 } 66 /*just for second level:.div1>.bigp*/ 67 68 </style> 69 </head> 70 <body> 71 72 <div>hello div</div> 73 <p id="littlep">hello p</p> 74 <p class="bigp">ppp</p> 75 <p class="bigp">pp</p> 76 <p>p</p> 77 78 <div class="bigp">div</div> 79 80 <a href="">aaa</a> 81 82 <div class="div1"> 83 <div> 84 <a href="">a</a> 85 <p>pppppp</p> 86 <div>div3</div> 87 </div> 88 <p>pppppppppp</p> 89 <div class="div2">div2</div> 90 </div> 91 <div>after div1</div> 92 <p>after div1 p</p> 93 94 <!--attribute selector:--> 95 96 <div>hello1</div> 97 <div alex="sb">alex</div> 98 <div alex="dasb">hello2</div> 99 <p alex="dasb">pppppp</p> 100 <div alex="ls lis">hello3</div> 101 102 </body> 103 </html>