November 2011
Intermediate to advanced
384 pages
13h 23m
English
You can select any HTML element by assigning it a class or ID name and then using that name in CSS as a part of your element selector. Once selected, CSS declarations can be applied to stylize the matching HTML code:
element.class { ... }element#id { ... }
How do you decide which method to use as your selector?
Simply put, an ID should be used only as a proper name, assigned to only one element per page. It should be a specific object or component that requires dedicated CSS rules. For example, a site logo image could be assigned an ID in HTML with <img src='logo.jpg' id='logo'> and be stylized in CSS via img#logo{...}, or just #logo{...}, as the element prefix is optional.
A class should be used ...
Read now
Unlock full access