From the course: CSS: Design Systems and Architectures
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Class-based CSS - CSS Tutorial
From the course: CSS: Design Systems and Architectures
Class-based CSS
- [Narrator] Good CSS architecture should be reusable and flexible, which is why many developers are opting to stop using ID selectors and only using type selectors for base styles and classes for any other CSS. Classes can be use multiple times on the same page, and multiple classes can be added to the same element. IDs, on the other hand, can only be used once per page and once per element. IDs also have a higher specificity level. So using them sparingly or not at all can reduce some potential specificity issues. Choosing classes as a convention can also make your HTML easier to read. If you see an ID in the HTML, then you'll know that it's only there for nonstyling purposes, such as in page linking, or used as a hook for JavaScript. Whether you choose to follow a class base CSS architecture or continue to use IDs, naming conventions should be established for consistency. Here are some rules I like to keep in mind. Use lowercase letters only, and decide whether to use dashes…
Contents
-
-
-
-
-
(Locked)
Overview1m 32s
-
(Locked)
Defining the stages and categories4m 40s
-
(Locked)
Editor settings, tools, and setup2m 21s
-
(Locked)
Formatting rules1m 50s
-
(Locked)
Class-based CSS1m 39s
-
(Locked)
Naming conventions with SMACSS3m 6s
-
(Locked)
Base styles3m 6s
-
(Locked)
Modular CSS3m 25s
-
(Locked)
Responsive2m 16s
-
(Locked)
Templates1m 31s
-
(Locked)
-