negative margins

key points

  • unlike padding and border width, you can assign a negative value to margins.

  • ⭐️ negative margins allow elements to overlap or stretch wider than their containers.

  • ⭐️ negative left or top margins pull the element leftward or upward.

  • ⭐️ negative right or bottom margins will pull the succeeding element(s) leftward or upward (to overlap).

Using negative margins to overlap elements can render some elements unclickable if they’re moved beneath other elements.

Last updated