Skip to main content
Practice

Setting Margin Orientation

Margins and padding can be set to specific directions using top, bottom, left, and right properties.

Top, bottom, left, and right correspond to the margins at the top, bottom, left, and right parts of an element respectively.

Applying CSS properties to the 'box' class
.box {
margin-top: 10px; /* 10px margin at the top */
padding-bottom: 20px; /* 20px padding at the bottom */
margin-left: 10%; /* Adds a left margin of 10% of the element's width for the elements with 'box' class */
}

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.