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

CSS margin/padding property values

CSS margin/padding property values Bad Practice
CSS margin/padding property values Best Practice

A pixel isn't the only measurement unit that we can use for defining elements' values. All padding and margin properties can specify their values in:

  • Length: You can use familiar pixels or points (pt), centimeters (cm), and other measurement units.
  • Percentage (%): You specify a property in the percentage of the container's width.
  • Global values: These values (inherit, initial, or unset) indicate how the padding and margin properties inherit values from the parent element or reset to their browser defaults.
Improve your UX & Product skills with interactive courses that actually work