0
0
CSSmarkup~20 mins

Naming conventions in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
CSS Naming Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding BEM Naming Convention
Which of the following CSS class names correctly follows the BEM (Block Element Modifier) naming convention for a button component with a disabled state?
Abutton_disabled
Bbutton--disabled
Cbutton__disabled
Dbutton-disabled
Attempts:
2 left
💡 Hint
BEM uses double hyphens for modifiers and double underscores for elements.
📝 Syntax
intermediate
2:00remaining
Valid CSS Class Name Syntax
Which of these CSS class names is invalid according to CSS naming rules?
A2nd-section
Bfooter_nav
C_header-main
DcontentArea
Attempts:
2 left
💡 Hint
CSS class names cannot start with a digit.
selector
advanced
2:00remaining
Selector Specificity with Naming Conventions
Given these CSS classes, which selector has the highest specificity?
CSS
.nav__item { color: blue; }
.nav--active .nav__item { color: red; }
.nav__item--highlighted { color: green; }
A.nav--active .nav__item
B.nav__item, .nav--active
C.nav__item--highlighted
D.nav__item
Attempts:
2 left
💡 Hint
More class selectors in a selector increase specificity.
layout
advanced
2:00remaining
Naming Conventions Impact on CSS Grid Layout
If you have a CSS Grid container named grid-container and grid items named grid-item--large and grid-item--small, which CSS rule correctly applies a larger grid area to the large item using these class names?
A.grid-container .grid-item-large { grid-area: 1 / 1 / 3 / 3; }
B.grid-item_large { grid-area: 1 / 1 / 3 / 3; }
C.grid-item--small { grid-area: 1 / 1 / 3 / 3; }
D.grid-item--large { grid-area: 1 / 1 / 3 / 3; }
Attempts:
2 left
💡 Hint
Match the exact class name with correct syntax.
accessibility
expert
3:00remaining
Naming Conventions and Accessibility in CSS
Which naming convention practice best supports accessibility when styling components for screen readers and keyboard navigation?
AUse only IDs for styling to ensure uniqueness and avoid confusion.
BUse short, generic class names like <code>a1</code>, <code>b2</code> to keep CSS file size small.
CUse descriptive class names that reflect the component role, like <code>btn-submit</code> or <code>nav-link</code>.
DAvoid naming conventions and rely on inline styles for accessibility.
Attempts:
2 left
💡 Hint
Good naming helps assistive technologies understand page structure.