What are CSS selectors? List the main types.

Answer

CSS selectors are patterns used to target and style HTML elements. The main types are: Element selector (p { }) targets all elements of a type. Class selector (.btn { }) targets elements with a specific class. ID selector (#header { }) targets a unique element by ID. Attribute selector ([type="email"] { }) targets elements with specific attributes. Pseudo-class selector (a:hover { }) targets elements in a specific state. Pseudo-element selector (p::first-line { }) targets a specific part of an element. Combinator selectors like descendant (div p), child (div > p), and sibling (h1 + p) target elements based on their relationship in the DOM.