Starlit Daily

📚 › CSS: style and layout

5. The box model: padding, border, margin

ستتم ترجمة هذا المقال تلقائيًا. يُعرض بالإنجليزية حاليًا.

Every element is a box: content, then padding (space inside the border), then the border, then margin (space outside the border).

padding: 12px sets all four sides. padding: 8px 16px sets top-bottom and left-right. The same shorthand works for margin.

عرض المثال

.box {
  padding: 12px;
  border: 2px solid navy;
  margin: 20px;
}

✍️ دورك الآن

Give .box a padding of 24px and a dashed border of 3px.

← العودة إلى الدورة