From the course: CSS Essential Training
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Margin collapse and inline spacing
From the course: CSS Essential Training
Margin collapse and inline spacing
- [Instructor] Now that we've covered how to use the box model properties, let's go over a couple of box model quirks and how to manage them, starting with Margin Collapsing. When two elements containing margin space appear one after another, the bottom margin of the first element and the top margin of the second element occupy the same space. Let's look at an example on CodePen. We'll start by taking a look at the two paragraphs, which are also block elements. I've added background colors to make it easier to see the default spacing. Let's say you wanna remove the space in between the two paragraphs. Inside of Block 1, let's un-comment the margin-bottom style. Set to zero to remove the space from the bottom of the first paragraph. It looks like there's been no change, but remember, this space is also occupied by the top margin in the second paragraph, so let's remove that margin space, which is using the Block…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Introduction to the CSS box model1m 4s
-
(Locked)
Width, height, and display3m 7s
-
(Locked)
Padding, margin, and border4m 59s
-
(Locked)
Center-aligning with margin3m 7s
-
(Locked)
Box-sizing and the box model fix3m 31s
-
(Locked)
Working with developer tools5m 1s
-
(Locked)
Margin collapse and inline spacing2m 48s
-
(Locked)
Creating full-height layouts3m 2s
-
(Locked)
Project: List reset and header updates4m 51s
-
(Locked)
Project: Centering content with margin5m 49s
-
(Locked)
Project: Heading resets and border styles4m 4s
-
(Locked)
-
-
-
-
-
-