QuickDevGuide

Home › CSS

Pseudo Classes & Elements — CSS

Pseudo classes style elements based on user interaction or state — they add interactivity without JavaScript. Pseudo elements style specific parts of elements. Common Pseudo Classes :hover — mouse is over the element (a:hover { color: red; }). :active — element is being clicked (button:active { background: green; }). :focus — element has keyboard focus (input:focus { border-color: blue; }). :first-child, :last-child — targets first/last child of a parent. :nth-child(2n) — targets every even element (useful for table striping). :not(.hidden) — targets elements that do NOT match a selector. Common Pseudo Elements ::before and ::after — insert generated content before/after an element's content. ::first-line — styles the first line of text. ::first-letter — styles the first letter (used for…

Key Takeaways