Pseudo-classes select elements based on their state or position. Pseudo-elements create virtual elements for styling specific parts.
Common Pseudo-classes
:hover— when mouse is over the element:focus— when the element has focus (input, button):active— while the element is being clicked:first-child/:last-child— first/last child of parent:nth-child(n)— nth child (e.g.,:nth-child(odd),:nth-child(3n)):not(selector)— selects elements NOT matching the selector:disabled/:checked— form element states
Common Pseudo-elements
::before— inserts content before the element::after— inserts content after the element::first-line— first line of text::first-letter— first letter of text::placeholder— styles input placeholders