margin-trim

An experimental property that 'trims' the margins of child elements when they hit the edges of their container. It's a cleaner way to handle things like the last item's margin-bottom.

It is documented as part of the CSS Box Model specification. This is an experimental technology. The syntax and behavior are still subject to change.

/* Usage Example */
.container {
  /* Automatically removes bottom margin from the last child */
  margin-trim: block-end;
}

/* Syntax */
margin-trim: none;
margin-trim: in-flow;
margin-trim: all;

/* Global values */
margin-trim: inherit;
margin-trim: initial;
margin-trim: revert;
margin-trim: revert-layer;
margin-trim: unset;
Limited availability Since 2020 13% global usage

This feature is not Baseline because it does not work in some of the most widely-used browsers.

16.4+
Kinsta

Your first month is free

Managed WordPress hosting for faster sites.

Learn more

New CSS drops.

Join 600+ readers who've survived clearfix hacks.

ESC