3_css优先级.html 700 B

12345678910111213141516171819202122232425262728
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. #div1{
  10. background: red;
  11. }
  12. .aa{
  13. background: green;
  14. }
  15. div{
  16. background: blue;
  17. }
  18. </style>
  19. </head>
  20. <body>
  21. <!-- css选择器的优先级
  22. style在标签上的样式 > id选择器 > class选择器 > 标签选择器
  23. 1000 100 10 1
  24. -->
  25. <div id="div1" class="aa" style="background: orange;">qqqqgfhjkl;</div>
  26. </body>
  27. </html>