样式表之优先级
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 <style type="text/css"> 7 .box{ 8 font-size:100px; 9 color:green; 10 } 11 div{ 12 font-size:40px !important; 13 color:pink !important; 14 } 15 #con{ 16 color:red; 17 font-size:200px; 18 } 19 20 </style> 21 </head> 22 <body> 23 <div class="box" id="con" style="font-size:12px; color:green;">中文</div> 24 </body> 25 </html>
优先级:
默认样式(0)<标签选择器(1)<类选择器(10)<ID选择器(100)<行内选择器(1000)<!important(1000以上)
0 1 10 100 1000 1000以上