[CSS basic knowledge] in the CSS ID and the distinction between Class

Related Tags:

  (Http://www.8go8.com/blog/post/20060612013036.html) 

  This distinction between the two are relatively easy to confuse the issue, especially with the class ID, I believe many people do not have a detailed understanding of the distinction.    Following is my understanding: 

  1.Class and the difference between a Class id is used according to user-defined criteria for one or more elements of a definition.    Make a more appropriate analogy is the scenario: a Class can be defined in each script the story line figures, you can CSS, Javascript, and so the use of this class.    Therefore you can use on a page in the class = "Frodo" class = "Gandalf" class = "Aragorn" to distinguish between the different story lines.    Another point is very important in a document you can use any number of Class. 

  As for the ID, usually used to define a page only once markings.    In the page layout of the structural layout (for instance, a page is usually a header from a header    , A regional content and composition of such a footer), the general use of an ID ideal, because a ID in a document can only be used once.    These elements in the same page there will be little more than a situation. 

  Summed up in one sentence: Class can be repeated use of ID in a page can only be used once.    Most likely in a browser repeatedly use the same ID will not be a problem, it is the standard, this is the wrong use, but is likely to lead to some real problems of the browser.    (Just in Dreamweaver tried to, and indeed, there is no error) 

  In practical applications, the text of the Class may be more useful, such as typesetting, and ID is on the macro layout and design at various elements more useful. 

  Padding 2.Margin and replace the distinction between the two forms are the most important role -> block segmentation good way Margin is the difference between the different Tag isolated from each other and Padding is the same elements of the different aspects of the use of segmentation, which most clearly seen in the table.    Particularly when the load on the Background of a regional style, the content of Padding under the background Color will be changed, and Margin will not be changed. 




Related articles:

Using Dreamweaver document library website updated
  Often we in the establishment of a relatively large site when there are many pages of the framework model and even some of the small details are the same elements, but disturbing is the cost to update them when some setbacks, we must also kept repeated updated each page element.    ...
Optimization of cheating website
  Website optimization some heretical, but it is often only temporary Qiao review, the end result is wasted.    Search engines, especially the large search engine in the detection of fraud is very smart, so careful not to adopt the best cheating following:    .................
Ajax use experience
  1, the first time in the load process of registration to Ajax    Such as: private void Page_Load (object sender, EventArgs e)    (    Ajax.Utility.RegisterTypeForAjax (typeof (BD0047)); / / Add Ajax in the category BD0047    )    2, in t...
Mobile text will be produced
  Basic syntax:    <marquee> Need mobile text </ marquee>    <direction=#>    1. Direction # = left, right    Example: <marquee direction = left> right to left mobile </ marquee>>    <marquee Direction=ri...
Rookie of using Dreamweaver MX 2004 act (13) Drag Layer
  Original content of this site, please specify the source of reproduced I love DivCSS.    Drag Layer    Drag-drag moves to allow visitors layer.    Use this action to create puzzle games, slider controls and other mobile interface elements.    You ca...