Stats

186 Contributors: 13 Wednesday, November 9, 2016
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

Margins

Syntax

  • margin: <top & right & bottom & left>;
  • margin: <top>, <left & right>, <bottom>;
  • margin: <top & bottom>, <left & right>;
  • margin: <top>, <right>, <bottom>, <left>;
  • margin-top: <top>;
  • margin-right: <right>;
  • margin-bottom: <bottom>;
  • margin-left: <left>;

Parameters

ParameterDetails
0set margin to none
autoused for centering, by evenly setting values on each side
units (e.g. px)see parameter section in Units for a list of valid units
inheritinherit margin value from parent element
initialrestore to initial value

Remarks

More on "Collapsing Margins": here.

Related Examples