Explain the concept of specificity in CSS.

Specificity determines which CSS rule applies when multiple rules target the same element. IDs have higher specificity than classes, which are higher than element selectors.