← View in Interactive Graph

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.

Real-World Comparison

Think of it like setting up a Data Science environment:

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:


Tags: #web-dev

Styling_CSS