CSS Syntax — CSS Technical Interview Questions & Answers
Selectors, declarations, properties and values.
CSS Syntax
- Selectors, declarations, properties and values.
- A rule: selector, then { declarations }. Each declaration is property: value; with a semicolon. /* comment */. Multiple selectors: h1, h2 { font-family: sans-serif; }
- Missing semicolon makes the next property die. That’s the first thing to check.
- Trap: using = instead of :. Trap: quotes around navy.
Technical Interview Tip: .card { padding: 16px; color: navy; }
Code Examples for CSS Syntax
CSS Syntax — working example
/* selector { property: value; } */
.button {
background-color: #2563eb;
color: #ffffff;
padding: 0.5rem 1rem;
border-radius: 0.375rem;
}CSS Syntax — a rule set = selector + declaration block; each declaration is property: value;.
How to Explain CSS Syntax to an Interviewer
Parts of a CSS rule?
Selector Property Value