Tutorials

CSS Tutorial

All Tutorials Learning Tools Login

CSS Tutorial · Chapter 4 of 7

CSS Box Model

Understand padding, border, and margin.

Padding is space inside an element. Margin is space outside. Border sits between them.

Changing padding often improves readability quickly.

Box model sample Try it Yourself »
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>CSS Tutorial</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <section class="card">
        <h1>CoderKiosk CSS Lab</h1>
        <p class="muted">Style this page using CSS.</p>
        <button class="primary">Start Lesson</button>
    </section>
</body>
</html>
style.css
.card {
    margin: 40px auto;
    width: min(420px, 90vw);
    padding: 32px;
    border: 2px solid #cbd5e1;
    border-radius: 18px;
    background: white;
}

body {
    font-family: Arial, sans-serif;
    background: #f8fafc;
}

Classroom Tips

  • Inspect spacing one property at a time.
  • border-radius softens corners.