DEV Community

Cover image for TIL - CSS Box Model
Anne Quinkenstein
Anne Quinkenstein

Posted on

3 2

TIL - CSS Box Model

Box-Model Properties

display: block display: inline display: inline-block
default at <h1> and <p> <span> and <em>
width width as the container width as the inline Element
width & height properties are respected. width and height properties will not apply
Padding, margin and border will cause other elements to be pushed away from the box will apply. Vertical will not cause other inline boxes to move away from the box/ Horizontal will cause other inline boxes to move away from the box causes the padding to be respected by other elements
centering stuff block box with {margin: 20px auto; /* Vertical Horizontal */} inline box with {text-align: center}

Tips

-> more on centering

get rid of the default white space in some browsers from margin/padding added by your browser.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

Dev Tools

Chrome
Mozilla1, Mozilla2

first step

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay