health-check domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/yogisv5/sitesbyyogi.com/wp-includes/functions.php on line 6260Objective: Understand how every element is a rectangular “box” and learn to control size, spacing, and borders precisely.
Every visible element is composed of Content → Padding → Border → Margin.
+---------------------------+
| Margin |
| +---------------------+ |
| | Border | |
| | +---------------+ | |
| | | Padding | | |
| | | +-----------+ | | |
| | | | Content | | | |
| | | +-----------+ | | |
| | +---------------+ | |
| +---------------------+ |
+---------------------------+
| Property | Description | Example |
|---|---|---|
| Content | The actual text or image inside the element | width, height |
| Padding | Space between content and border | padding: 20px; |
| Border | Outline around the element | border: 2px solid #000; |
| Margin | Space outside the border (between elements) | margin: 20px; |
.box {
width: 300px;
padding: 20px;
border: 5px solid #0E477B;
margin: 15px;
background-color: #f5f5f5;
}
Renders a 300px content box with inner padding, blue border, and outer margin.
By default, width targets only the content area. Include padding and borders with:
* {
box-sizing: border-box;
}
✅ Best practice: Use globally. Layout math gets much simpler.
| Display | Behavior | Example |
|---|---|---|
block | Starts on a new line; full width | <div>, <p>, <section> |
inline | Flows within text; width is content | <span>, <a>, <img> |
inline-block | Inline flow + box properties | Often used for buttons, badges |
none | Element not rendered | Used for toggles/modals |
span {
display: inline-block;
padding: 5px 10px;
border: 1px solid #333;
}
/* Top, Right, Bottom, Left */
margin: 10px 20px 15px 5px;
/* Top/Bottom, Left/Right */
padding: 10px 20px;
/* All sides equal */
margin: 20px;
💡 DevTools (F12) → “Elements” → “Box Model” visualizes spacing live.
div {
border: 3px dashed #6EC1E4;
border-radius: 10px;
}
Common styles: solid, dashed, dotted, double, none.
✅ Exercise 1: Create a “Card” Layout
<div class="card">
<h2>StreetGeek Course</h2>
<p>Learn HTML, CSS, and PHP step-by-step.</p>
</div>
.card {
background-color: #ffffff;
border: 2px solid #0E477B;
border-radius: 10px;
padding: 20px;
margin: 20px auto;
width: 300px;
box-shadow: 2px 2px 8px rgba(0,0,0,0.1);
}
💡 Tweak padding and margin to feel the difference.
.box {
display: inline-block;
width: 45%;
margin: 2%;
background: #f9f9f9;
padding: 10px;
border: 1px solid #ccc;
}
box-sizing: Use border-box for simpler widths.font-size:0 on parent (then reset on children) if needed.box-sizing: border-box do?Create a “Course Info Card Grid” with:
<h3>), description, border, padding, rounded corners, and shadow..card-grid{
display:grid;
grid-template-columns:repeat(3,1fr);
gap:16px;
}
.card-grid .card{
background:#fff; border:2px solid #0E477B; border-radius:12px;
padding:18px; box-shadow:0 8px 18px rgba(0,0,0,.06);
transition:transform .3s ease;
}
.card-grid .card:hover{ transform:scale(1.05); }
border-boxNext up: 👉 MODULE 7: Layout with Flexbox & Grid — build responsive, multi-column layouts.