ID selector


ID选择器

1
<!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 <style type="text/css"> 7 #logo{ 8 font-size:20px; 9 background-color:pink; 10 color:green; 11 width:120px; 12 height:80px; 13 14 } 15 #box{ 16 text-align:center; 17 } 18 .hot{ 19 text-indent:2em; 20 } 21 </style> 22 </head> 23 <body> 24 <div id="logo" class="hot">博博</div> 25 <div>俊俊</div> 26 <p>奋奋</p> 27 <p>斗斗</p> 28 </body> 29 </html>

Writing:
◆ #custom name{attribute:value}
Features:
◆ An ID selector can only be used once on a page. If it is used twice or more, it does not conform to the W3C specification, and there will be problems with JS calls.
◆ A tag can only be used With an ID selector
A label can call both the class selector and the ID selector

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325024978&siteId=291194637