Explain the concept of CSS specificity.
Instruction: Define what CSS specificity is and give an example of how it works.
Context: This question is designed to test the candidate's understanding of CSS specificity rules and how they influence the application of styles.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
Specificity is a selector comparison used within the cascade after earlier precedence decisions. It is not a universal numeric score that defeats origins, importance or layers.
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS example</title> <style> #header { color: navy; } .menu { color: darkgreen; } div { color: maroon; } :where(#header) { background: #eee;...