Skip to Content
Boundaries and Space
Working with Margin

The CSS margin property controls the space between different HTML elements on a webpage. Use margin to bring page elements closer together or to move them further apart.

The CSS below ensures 2rems of space between elements with the class answer and surrounding page elements.

.answer { margin: 2rem; }



In main.css, locate the .gallery-item class selector. Currently, it has a margin of 2px. Change the value to 20px.

Run your code to see the space increase between each gallery item.

Folder Icon

Take this course for free

Already have an account?