A CSS rule has a selector and a declaration block.
selector {\n property: value;\n}
Parser rules that matter
- Missing semicolon can break following declarations.
- Invalid property names are ignored silently.
- Unknown values invalidate only that declaration.
Pitfall
CSS errors usually do not throw visible exceptions; you must inspect computed styles in DevTools.
Important interview questions and answers
- Q: Is semicolon required after the last declaration?
A: Technically optional, but always include it to avoid accidental breakage. - Q: What happens to unknown properties?
A: Browsers ignore them and continue parsing the rest. - Q: How do comments work in CSS?
A: Use/* ... */; single-line//is not standard CSS.
Pitfall: Check cascade order—author stylesheet loses to inline styles and !important surprises.