color — CSS Technical Interview Questions & Answers

The text (foreground) color of an element.

color

  • The text (foreground) color of an element.
  • color is a CSS property: it changes how a selected element looks or sits. You write it inside a rule: .card { color: …; }
  • Change one value, refresh, say what moved: colour, space, size, or stacking. That is how you learn properties — not by memorising the spec.
  • Trap: putting it on the wrong selector (parent vs child). Trap: px only on a phone page — learn rem/%/flex too when it is layout.
  • Box model reminder: width/height, padding, border, margin are different. If color is about space, draw the box.

Technical Interview Tip: color: one rule on .card, then say what changed.

Code Examples for color

color — working example

.named { color: crimson; }
.hex { color: #2563eb; }
.rgb { color: rgb(37, 99, 235); }
.rgba { color: rgba(37, 99, 235, 0.75); }
.hsl { color: hsl(221 83% 53%); }
.hsla { color: hsl(221 83% 53% / 0.75); }

color — foreground color accepts named, HEX, RGB(A), and HSL(A) values; alpha controls transparency.

How to Explain color to an Interviewer

What does color do?

A CSS property that changes look/layout Write it in a rule and refresh