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 閱讀(368) 評論(0)  編輯  收藏 所屬分類: CSS
          主站蜘蛛池模板: 隆化县| 龙南县| 仙游县| 积石山| 教育| 永川市| 永兴县| 海淀区| 遂平县| 红桥区| 平度市| 浮梁县| 普格县| 巫山县| 兰西县| 龙海市| 武汉市| 常德市| 萨迦县| 虹口区| 古交市| 尚志市| 集贤县| 广河县| 阜康市| 凤山县| 紫金县| 揭西县| 诸暨市| 林西县| 遵义市| 北安市| 雅安市| 灵山县| 财经| 利津县| 东乡族自治县| 江北区| 定边县| 黎城县| 西乌珠穆沁旗|