border — CSS Technical Interview Questions & Answers

Width, style and color of an element's border.

border

  • Width, style and color of an element's border.
  • border is a CSS property: it changes how a selected element looks or sits. You write it inside a rule: .card { border: …; }
  • 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 border is about space, draw the box.

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

Code Examples for border

border — working example

.card {
  border-width: 2px;
  border-style: solid;
  border-color: #94a3b8;
}

/* Shorthand */
.panel {
  border: 1px dashed #64748b;
  border-bottom: 3px solid #2563eb;
}

Borders need width + style (required) + color; shorthand sets all sides, longhands override one side.

How to Explain border to an Interviewer

What does border do?

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