CSS
June 3, 2026 2 min read

CSS Selectors: A Comprehensive Guide to Element, Id, Class, and Pseudo Selectors

HS
HEMANT SINGH
Technical Writer & Educator

CSS selectors list

Simple Selectors

Element SelectorSelect html element using name 
Id selectorSelect element using id attributes 
Class SelectorSelect element using class attriubutes 
Universal SelectorTo select all elements 
Grouping SelectorTo select multiple element together 

Combinator Selectors

Descendents SelectorSelect all childrens of specified element(space) 
Child SelectorSelect only direct child of specified element(>) 
Adjacent sibling selectorSelect next neighbour of specified element (+) 
Sibling selectorsSelect all neighbours of specified element (~) 

Pseudo class selectors

:activeSelect item, when item is clicked 
:hoverSelect item, when item hovered 
:linkSelect item, when a link is applied 
:visitedSelect item, when a link visited 
:checkedSelect item, when checkbox checked 
:disabledSelect item, when item is disabled 
:emptySelect all elements that has no childrens 
:enabledSelect enabled input fields 
:focusSelect input field when focused 
:first-childSelect every element that is first child  
:last-childSelect every element that is last child 
:nth-child(n)Select nth child 

Pseudo Elements

::first-letterSelect first letter of element 
::first-lineSelect first line of element 
::beforeDisplay content before the content of an element 
::afterDisplay content after the content of an element 
::selectionApply css properties when text selected