Skip to main content

Can margin be set to a negative value?

margin can be negative.

Behavior features:

  • the element can "shift" and overlap neighboring blocks;
  • a negative margin-top and margin-left pull the element closer to the preceding content;
  • a negative margin-bottom and margin-right can pull neighboring elements inward;

This is valid per the specification and is often used, but requires care so as not to break the structure.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.