<?xml version="1.0" encoding="utf-8"?>

CSS margin/padding properties for individual sides

CSS margin/padding properties for individual sides Bad Practice
CSS margin/padding properties for individual sides Best Practice

Instead of using a common padding property, you can specify each value separately with the padding-top, padding-right, padding-bottom, and padding-left properties. Likewise, you can define margin-top, margin-right, margin-bottom, and margin-left properties individually. All values should be specified in px, em, pt, cm, or percentage.

Pro Tip: Unlike padding, margin can have a negative value. A top/left negative value pulls the element in the specified direction, while a bottom/right clashes a succeeding element with the main one.

Improve your UX & Product skills with interactive courses that actually work