0
0
CSSmarkup

Class selectors in CSS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a class selector in CSS?
A class selector targets HTML elements with a specific class attribute. It starts with a dot (.) followed by the class name.
Click to reveal answer
beginner
How do you write a CSS rule to style all elements with the class highlight?
Use <code>.highlight { /* styles here */ }</code>. The dot means 'class', and <code>highlight</code> is the class name.
Click to reveal answer
intermediate
Can an HTML element have multiple classes? How does CSS handle that?
Yes, an element can have many classes separated by spaces. CSS applies styles from all matching class selectors to that element.
Click to reveal answer
beginner
What is the difference between a class selector and an ID selector?
A class selector starts with a dot (.) and can be used on many elements. An ID selector starts with a hash (#) and should be unique to one element.
Click to reveal answer
intermediate
How do class selectors help with responsive design?
Class selectors let you group elements and apply styles that can change with screen size using media queries, making layouts adapt easily.
Click to reveal answer
Which symbol starts a class selector in CSS?
A.
B#
C*
D$
How do you select all elements with class 'menu' in CSS?
Amenu
B#menu
C.menu
D*menu
If an element has class="btn primary", which selectors apply styles to it?
A.btn only
B#btn and #primary
C.primary only
D.btn and .primary
Which selector should be unique on a page?
AID selector
BElement selector
CClass selector
DUniversal selector
What is the correct way to write a CSS rule for class 'card'?
A#card { }
B.card { }
Ccard { }
D*card { }
Explain how class selectors work in CSS and how you use them in HTML.
Think about how you mark elements in HTML and then style them in CSS.
You got /4 concepts.
    Describe the difference between class selectors and ID selectors and when to use each.
    Consider how many elements each selector can target.
    You got /4 concepts.