CSS selectors, combinators, pseudo-classes, specificity, cascade, inheritance, box model, units and colors.
41 cards · basic cards · AI-written, checked twice. Edit anything.
- What selector targets an HTML element by its class name?
Show answer
The class selector, using a dot (.) prefix, e.g., .classname
- What selector targets an HTML element by its ID?
Show answer
The ID selector, using a hash (#) prefix, e.g., #idname
- What selector targets all elements of a given type?
Show answer
The element or type selector, e.g., p, div, span
- What is the universal selector in CSS?
Show answer
The asterisk (*), which targets all elements on the page
- What combinator is used to select all descendant elements?
Show answer
The space character (descendant combinator), e.g., div p selects all p elements inside any div
- What combinator selects only direct child elements?
Show answer
The greater-than symbol (>), e.g., div > p selects p elements that are direct children of div
- What combinator selects an element that immediately follows another?
Show answer
The adjacent sibling combinator (+), e.g., h1 + p selects the first p immediately after an h1
- What combinator selects all siblings that follow an element?
Show answer
The general sibling combinator (~), e.g., h1 ~ p selects all p elements that follow an h1
- What is an attribute selector? Give an example.
Show answer
A selector that matches elements based on their attributes, e.g., input[type="text"] selects input elements with type="text"
- What pseudo-class targets an element when the user hovers over it?
Show answer
:hover
- What pseudo-class represents an element that has received focus?
Show answer
:focus
- What pseudo-class targets the first child element of its parent?
Show answer
:first-child
- What pseudo-class targets the last child element of its parent?
Show answer
:last-child
- What pseudo-class selects elements based on a formula, like every other element?
Show answer
:nth-child(), e.g., li:nth-child(2n) selects every second list item
- What pseudo-element inserts content before an element's content?
Show answer
::before