2_选择器.html 650 B

123456789101112131415161718192021222324252627
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <style>
  8. /* div{
  9. color: red;
  10. } */
  11. /* 以"."开头的选择器称为类选择器 */
  12. /* .div1{
  13. color: red;
  14. } */
  15. /* 以#开头的选择器为ID选择器 且是唯一的 */
  16. #divid{
  17. color: red;
  18. }
  19. </style>
  20. </head>
  21. <body>
  22. <div class="div1" id="divid">hello</div>
  23. <div>world</div>
  24. <div class="div1">你好</div>
  25. <div style="color:blue">世界</div>
  26. </body>
  27. </html>