Jul 16, 2025
This lecture explains CSS pseudo-classes: keywords added to selectors to style elements based on their state, attributes, structure, or interaction.
:hover
) added to selectors to style elements in a specific state.selector:pseudo-class { property: value; }
:defined
 — selects elements that have been defined.:open
, :popover-open
, :modal
, :fullscreen
, :picture-in-picture
 — select elements based on their viewing or modal state.:enabled
, :disabled
, :read-only
, :read-write
, :placeholder-shown
, :autofill
:default
, :checked
, :indeterminate
, :blank
, :valid
, :invalid
, :in-range
, :out-of-range
, :required
, :optional
, :user-valid
, :user-invalid
:dir()
 — selects elements by text direction (ltr/rtl).:lang()
 — selects elements by language.:any-link
, :link
, :visited
, :local-link
 — select link states.:target
, :target-within
, :scope
 — select based on URL fragments or reference points.:playing
, :paused
, :seeking
, :buffering
, :stalled
, :muted
, :volume-locked
 — select media elements by playback or audio state.:current
, :past
, :future
 — select elements based on timing, e.g., captions.:root
, :empty
, :nth-child()
, :nth-last-child()
, :first-child
, :last-child
, :only-child
:nth-of-type()
, :nth-last-of-type()
, :first-of-type
, :last-of-type
, :only-of-type
:host
, :host()
, :host-context()
, :has-slotted
 — select elements inside/outside shadow DOM.:hover
, :active
, :focus
, :focus-visible
, :focus-within
 — select elements during interaction.:is()
, :not()
, :where()
, :has()
 — match elements using selector logic.:state()
 — select custom elements by their custom state.:left
, :right
, :first
, :blank
 — target pages in paged media/print CSS.