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 pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More CSS interview questions

View all →