O'Reilly logo
  • Richard Smith thinks this is interesting:

When deciding whether to use a class or an ID, follow these rules of thumb:

  • To use a style several times on a page, you must use classes. For example, when you have more than one photo on your page, use a class selector to apply styling—like a border—to each <img> tag you wish to style.

  • Use IDs to identify sections that occur only once per page. CSS-based layouts often use ID selectors to identify the unique parts of a web page, like a sidebar or footer. Part...


Cover of CSS: The Missing Manual, 2nd Edition


class and id selectors