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 閱讀(365) 評論(0)  編輯  收藏 所屬分類: CSS
          主站蜘蛛池模板: 柳江县| 渝北区| 邯郸县| 定陶县| 长岭县| 县级市| 银川市| 留坝县| 邢台市| 祁连县| 大埔区| 聂拉木县| 贺州市| 泽库县| 广昌县| 额尔古纳市| 桓台县| 伊春市| 精河县| 城口县| 中西区| 龙泉市| 剑河县| 社会| 陆河县| 格尔木市| 洪江市| 九寨沟县| 张家界市| 都昌县| 舞钢市| 德江县| 米林县| 鲜城| 龙胜| 毕节市| 那曲县| 罗田县| 青田县| 普兰店市| 依安县|