0
0
CSSmarkup~5 mins

Naming conventions in CSS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a naming convention in CSS?
A naming convention is a set of rules to name CSS classes and IDs clearly and consistently so that the code is easy to read and maintain.
Click to reveal answer
beginner
Why use the BEM naming convention?
BEM (Block Element Modifier) helps organize CSS by naming classes to show their role and relationship, making styles easier to understand and avoid conflicts.
Click to reveal answer
intermediate
Example of a BEM class name for a button inside a header block with a modifier for a large size?
header__button--large
Click to reveal answer
beginner
What is the benefit of using lowercase and hyphens in CSS class names?
Using lowercase letters and hyphens makes class names easy to read and type, and it avoids errors caused by case sensitivity.
Click to reveal answer
beginner
What should you avoid when naming CSS classes?
Avoid using vague names, spaces, special characters, or names that are too long or too short. Names should be meaningful and consistent.
Click to reveal answer
Which of these is a correct BEM class name for a modifier?
AbuttonActive
Bbutton--active
Cbutton_active
Dbutton.active
Why is it important to follow naming conventions in CSS?
ATo increase file size
BTo make code harder to read
CTo keep code consistent and easy to maintain
DTo avoid using classes
Which is a good practice for CSS class names?
AUse lowercase letters and hyphens
BUse uppercase letters randomly
CUse special characters like @ or #
DUse spaces in class names
In BEM, what does the 'Element' part represent?
AA CSS property
BA standalone block
CA modifier state
DA part inside a block
Which of these is NOT recommended for CSS class names?
AVery long and complicated names
BMeaningful names
CConsistent style
DUsing hyphens to separate words
Explain the BEM naming convention and why it helps in CSS.
Think about how BEM breaks down parts of a component.
You got /5 concepts.
    List three best practices for naming CSS classes.
    Focus on readability and avoiding errors.
    You got /5 concepts.