Sun River
          Topics about Java SE, Servlet/JSP, JDBC, MultiThread, UML, Design Pattern, CSS, JavaScript, Maven, JBoss, Tomcat, ...
          posts - 78,comments - 0,trackbacks - 0
           

          ---The key thing to know is that IDs identify a specific element and therefore must be unique on the page – you can only use a specific ID once per document. Many browsers do not enforce this rule but it is a basic rule of HTML/XHTML and should be observed. Classes mark elements as members of a group and can be used multiple times, so if you want to define a style which will be applied to multiple elements you should use a class instead.

           Notice that an ID's CSS is an HTML element, followed by a "#", and finally ID's name. The end result looks something like "element#idname". Also, be sure to absorb the fact that when an ID is used in HTML, we must use "id=name" instead of "class=name" to reference it!

          Why Did They Choose Those Names??

                 ID = A person's Identification (ID) is unique to one person.

                 Class = There are many people in a class.

          ID for Layout and Uniqueness

          Standards specify that any given ID name can only be referenced once within a page or document. From our experience, IDs are most commonly used correctly in CSS layouts. This makes sense because there are usually only one menu per page, one banner, and usually only one content pane.

          In Tizag.com CSS Layout Examples we have used IDs for the unique items mentioned above. View the CSS Code for our first layout example. Below are the unique IDs in our code.

          *       Menu - div#menuPane

          *       Content - div#content

          Answer: Classes vs IDs

          Use IDs when there is only one occurence per page. Use classes when there are one or more occurences per page.

          posted on 2010-03-16 10:14 Sun River 閱讀(364) 評論(0)  編輯  收藏 所屬分類: CSS
          主站蜘蛛池模板: 修水县| 泰安市| 乐山市| 巧家县| 类乌齐县| 呼玛县| 兰溪市| 朝阳区| 太保市| 银川市| 东平县| 左权县| 丰县| 泽普县| 交城县| 黑龙江省| 临高县| 巴彦县| 密山市| 台前县| 重庆市| 盘锦市| 黔西| 隆子县| 仁化县| 晴隆县| 新龙县| 曲靖市| 蒙山县| 工布江达县| 仙游县| 建阳市| 长春市| 顺义区| 普格县| 南昌县| 青河县| 濮阳县| 额敏县| 广饶县| 稻城县|