CSS Specificity — CSS Technical Interview Questions & Answers

How the browser decides which conflicting rule wins.

CSS Specificity

  • Specificity (css adv) is a CSS topic. In plain words you use it for a short Specificity css adv example in the look of a page. Don’t start with a slogan — start with that picture.
  • Smallest example: the smallest Specificity css adv example you can type. Type it, run it, and say what you see. If you can do that from memory, you know Specificity (css adv).
  • From the example next to this theory: How the browser decides which conflicting rule wins.
  • Trap: only saying “Specificity css adv” with no example. Fix that before you talk about advanced CSS.
  • Viva: what is Specificity (css adv)? Then show the smallest Specificity css adv example you can type. Then name the trap.

Technical Interview Tip: What is Specificity (css adv)? Show this: the smallest Specificity css adv example you can type. Trap: only saying “Specificity css adv” with no example.

Code Examples for CSS Specificity

CSS Specificity — working example

/* element */ p { line-height: 1.6; color: #334155; }
/* class */ .title { font-weight: 700; }
/* id */ #main { max-width: 960px; }
/* attribute */ input[type="email"] { letter-spacing: 0.02em; }
/* descendant */ .menu li { margin: 0.25rem 0; }
/* child */ .menu > li { list-style: none; }

/* Specificity roughly: inline > id > class/attr/pseudo-class > element */
/* Inherited: color, font-*; Usually not: margin, padding, border */

CSS Specificity — the cascade + specificity decide winners; some properties inherit (color/font), many layout ones do not.

How to Explain CSS Specificity to an Interviewer

What is Specificity (css adv)?

Used for a short Specificity css adv example the look of a page Not just the heading

Give one small example of Specificity (css adv).

the smallest Specificity css adv example you can type How the browser decides which conflicting rule wins

What mistake do beginners make with Specificity (css adv)?

only saying “Specificity css adv” with no example Show the fix

Where do you use Specificity (css adv)?

the look of a page a short Specificity css adv example