margin & padding
In web development, Margin and Padding are the two most important tools for controlling space. Since you want that clean, minimalist look like tedawf.com, mastering these is essential.
To understand margin: 0; and padding: 0;, we use the CSS Box Model.
The Graphical Explanation: The Box Model
![[css-box-model.jpg]] Imagine every element on your website (a heading, a paragraph, or a button) is a physical box.
-
Content: The actual text or image (e.g., "hi, i'm anku.").
-
Padding: The space inside the box, between the content and the border.
-
Border: The edge of the box.
-
Margin: The space outside the box, pushing other boxes away.
Real-World Comparison
Think of it like setting up a Data Science environment:
-
Default Browser Spacing: Like a laptop that comes with pre-installed bloatware.
-
margin: 0; padding: 0;: Like formatting your hard drive and installing a clean version of Linux so you know exactly what is running.
How it looks in your Code:
CSS
body {
margin: 0; /* Removes the gap between the edge of the screen and your site */
padding: 0; /* Removes any internal breathing room the browser might have added */
font-family: 'Inter', sans-serif;
}
Without margin: 0;, if you tried to give your site a background color, you would see a thin white border around the entire page.
Would you like to see how to add intentional padding to your container so your text doesn't touch the very edge of a phone screen?
Sources:
-
**** Standard CSS Box Model definitions and web layout principles.
-
**** Common practices for CSS resets and browser default styling.
-
**** Visual analysis of minimalist design trends (e.g., tedawf.com).
Tags: #web-dev