I guess they always use the id in examples because it’s less ambiguous. You know that they’re talking specifically about that one element and its styles.
In general, the rule of thumb is that you should ask yourself: “is there more than one element which requires the same style, now or at any time in the future?”, and the answer is even “maybe”, then make it a class.
Related Contents:
- What is the difference between :focus and :active?
- Is there a way to make a child DIV’s width wider than the parent DIV using CSS?
- MVC4 StyleBundle not resolving images
- How to select label for=”XYZ” in CSS?
- Suggestions for debugging print stylesheets?
- Absolute positioning ignoring padding of parent
- Disable webkit’s spin buttons on input type=”number”?
- Css pseudo classes input:not(disabled)not:[type=”submit”]:focus
- CSS styling in Django forms
- Column order manipulation using col-lg-push and col-lg-pull in Twitter Bootstrap 3
- Input widths on Bootstrap 3
- Padding within inputs breaks width 100%
- How can I add white space before an element’s content using CSS?
- How can I override inline styles with external CSS?
- Overflow to left instead of right
- Override element.style using CSS
- CSS to stop text wrapping under image
- How can I create a “tooltip tail” using pure CSS?
- CSS flex, how to display one item on first line and two on the next line
- How to reset/remove CSS styles for a specific element or selector only
- CSS: transform: translate(-50%, -50%) makes texts blurry [duplicate]
- Should border-radius clip the content?
- How to prevent Webkit text rendering change during CSS transition
- How can I download WOFF files from Google Fonts? [closed]
- How to use and how works CSS’ will-change property?
- CSS Flex Box Layout: full-width row and columns
- SASS CSS: Target Parent Class from Child
- Make input value uppercase in CSS without affecting the placeholder
- How to ignore parent element’s overflow:hidden in css
- Contain an image within a div?
- What Does ‘zoom’ do in CSS?
- How can I make a link inside a div fill the entire space inside the div?
- Symfony2 – Assetic – load images in CSS
- Blurring an image via CSS?
- Why does user agent stylesheet override my styles? [closed]
- Order of prioritization when using multiple contradictory css files
- How to use images in css with Webpack
- How to position two divs horizontally within another div
- CSS to hide INPUT BUTTON value text
- CSS: Left, Center, & Right Align Text on Same Line
- (CSS) Make a background image scroll slower than everything else
- CSS div width not working
- TinyMCE is removing tags
- LESS CSS set variables in media query?
- Fixed gradient background with css
- Combining :last-child with :not(.class) selector in CSS
- How to standardize the height of a select box between Chrome and Firefox? [closed]
- CSS white space at bottom of page despite having both min-height and height tag
- Flex auto margin not working in IE10/11
- How to wrap or truncate long strings in a Material-UI ExpansionPanelSummary