the.com/selector

The address you give a webpage element so JavaScript stops guessing and starts obeying.

means A pattern that picks out which element(s) in a document you mean — by tag, class, id, or relationship — so code or CSS can target them precisely.

from From 'select,' tracing back to Latin 'selectus' (past participle of 'seligere,' to choose — 'se-' apart + 'legere' to gather or pick). 'Selector' as a technical term for a device or code that chooses among options shows up in early electronics and telephony; CSS and later JavaScript's query APIs borrowed that same sense of 'the thing that does the choosing' for picking elements out of a page.

css vs js
css picks styles, js picks targets, same syntax
specificity wars
id beats class beats tag, always
nth-child trap
counts siblings, not matches, classic bug source
attribute selectors
can match partial text like input[name^=user]
the.com · every word