Why can't you use classes all over your document? In this video, learn best practices for mixing selectors in your document, including selecting with the least specificity, leveraging pseudo-classes and pseudo-elements, and minimizing the use of ID selectors.
- [Instructor] Now that you know all of these fabulous ways … to make selectors, what should you do? … Should you try out all of them … or should you just throw up classes everywhere you go? … It might seem easier especially to a beginner … to use classes for all of your styles everywhere. … Let's look at some best practices … in CSS selector choice. … Generally speaking in CSS, less is more. … Simple selectors with the least amount … of specificity for what you are trying to select … is what you want to use. … Classes everywhere means cluttering up your HTML … with potentially unneeded CSS classes … reducing code reusability. … And with every selector at the same level … of specificity, all of your styles … may fight with each other frequently. … The big C in CSS stands for Cascade … and when combined with inheritance, … this is your friend. … It makes styling simple, easy to override styles … with other options under different conditions. … If every selector is the same specificity, …
- Targeting classes and IDs
- Working with group selectors
- Targeting element attributes
- Targeting links with pseudo-class selectors
- Targeting child elements and empty elements
- Targeting parent, child, and sibling elements
- Best practices for CSS
- The impact of CSS selectors on performance
Skill Level Beginner
The power of selectors1m 8s
1. Review of Basic CSS
2. Combinator Selectors
3. Attribute Selectors
Simple attribute selectors2m 47s
4. Pseudo-Classes, Pseudo-Elements, and the Universal Selector
5. Choosing Selectors
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.