Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall
CSS beginners are often bothered by a problem when they start using the div layout: When defining a property, is it using an ID, or is it using class? Here I talk about the principles of using ID and class in my work. Hope to help beginners.
Principle of use of IDs
We know that ID is unique, that is, the ID in the entire XHTML can not be duplicated, so we write the page, the large structure with ID, such as: logo, navigation, subject content, copyright, according to the naming code, respectively named #logo, #nav, #contenter, # Copyright。 There is another situation: we have to use JS to effect a layer to achieve a certain effect, with the ID. This is also determined by the uniqueness of the ID.
The use principle of class
Class is universal in CSS definition and can be reused infinitely, which also embodies the superiority of div layout. Class is commonly used within structs, and the benefit of this is that it facilitates late maintenance and modification of site code, which makes all classes a child or grandchild of the ID.
Also note that try not to let class include IDs, such as. ff #childer {...}, which is obviously undesirable and does not conform to the writing habit. Also introduced in front of good writing habits, the code to write norms, and other colleagues to cooperate, so that later maintenance is very good.