Evo. G Tech Team Forum
Welcome to Evo. G Tech Team Forum. We have moved to a new website : www.evogtechteam.com

Thanks you.

by Evo. G Tech Team Management.

Join the forum, it's quick and easy

Evo. G Tech Team Forum
Welcome to Evo. G Tech Team Forum. We have moved to a new website : www.evogtechteam.com

Thanks you.

by Evo. G Tech Team Management.
Evo. G Tech Team Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

ID和CLASS的区别

Go down

ID和CLASS的区别 Empty ID和CLASS的区别

Post by too wei September 25th 2015, 14:30

id        在同一个页面,只可以被调用一次,在CSS里用“#”表示
class    在同一个页面可以调用无数次(没限制的),在CSS里用“.”表示

id就像是一个人的身份证号码,每个人都有一个独一无二的身份证号码
class就像是一个人的名字,有许多人的名字是一样的,但身份证号码并不相同

在下面这段代码里,id和class都被调用了2次,id和class都成功了,那是因为浏览器的容错性能好
按照html语法,一定遵循一个id命名在一个网页中只能使用一次
Code:
<html>
<head>
   <title>Evo. G Tech Team</title>
   <style>
   .blue_class
   {
      color : blue;
   }
   #red_id
   {
      color : red;
   }
   </style>
</head>
<body>
   <p class = "blue_class">Evo. G Tech Team</p>
   <p class="blue_class">I am Class</p>  
   
   <p id="red_id">I am ID</p>  
   <p id="red_id">Hello world</p>
</body>
</html>

too wei
Sponsor
Sponsor

Posts : 31
Points : 66211
Reputation : 0
Join date : 2015-04-21
Age : 25
Location : Johor

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum