seniorCSS
Explain the margin-trim property.
Updated Apr 28, 2026
Short answer
margin-trim solves the common problem of excess margins at the edges of a container.
Deep explanation
Instead of targeting the first or last child to remove their margin (e.g., li:last-child { margin-bottom: 0; }), you declare margin-trim: block on the parent container. It automatically trims any margins from the children that touch the container's inner edge.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro