The WPFolks app is out on iPhone and Android. Free, no ads. Download on the App Store Get it on Google Play
Skip to main content
Login Join
Snippet · CSS

Prevent Empty Elements from Taking Space

Shared by Hiral solanki · September 17, 2026

26 views
1 upvote
Back to Snippets

Automatically hides empty elements, which is particularly useful for WordPress templates where optional ACF fields may leave empty containers.

.element:empty {
    display: none;
}
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

1 comment

  1. Amit Dholiya
    Amit Dholiya @amitdholiya

    This is used to auto-hide empty containers — handy for ACF templates where optional fields can leave blank divs behind.

    Report

Proudly supported by