• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

4.3. class and id as Selectors

In preparation for the full implementation of CSS, the forward-looking HTML 4.0 specification (released in December 1997) added two new attributes: class and id. These new attributes can be applied universally to almost any Web element meant to be displayed within the body of a Web page. This makes sense, since CSS is designed to alter the display of visible elements on a Web page, and by definition that means that Web elements are displayed within the body of a Web page, and not, say, in the header of a Web page.

The idea behind class and id is that they identify the HTML tags with which they are associated as “targets” for CSS declarations that have previously been defined within the header of a Web page. class and id differ in that class is intended for general formatting across many elements on a Web page, whereas id is meant for specific formatting to a single instance — it is particularly useful when programming dynamic elements via JavaScript, for example, when you want to only affect a single element.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint