Memberstack
Pricing
API
Login
Build for free
Memberstack
Pricing
API
Login
Build for free
Memberstack
Pricing
API
Login
Build for free
Blog/How to Hide a Whole Section in Webflow when a List is Empty

How to Hide a Whole Section in Webflow when a List is Empty

This post will teach you how to hide a whole section when a list is empty in webflow, what the feature is and when/why you might want to hide a whole section when a list is empty in your project.

Ovidiu·Contributor
|
December 15, 2023·3 min read

How to hide a whole section in Webflow when a list is empty

Memberscripts needed

https://www.memberstack.com/scripts/hide-element-based-on-other-elements-children

Tutorial

Cloneable

https://webflow.com/made-in-webflow/website/filter-saved-cms-items

Why/Use Cases

  1. Hide empty sections that don’t serve any purpose when empty.
  2. Improve the user experience of creating custom lists.

Sometimes, depending on your users’ activity on your site, you may have certain sections without any content. To improve your users’ experience, you may want to hide any unnecessary sections and not crowd your UI.

We’re going to be looking at an example where users can favorite items on a list and based on whether they’ve favorited anything or not, show or hide the dedicated Favorites section.

How to hide an empty section on Webflow

To set this up, we’re going to use MemberScript #25 – Hide Element Based on Other Element’s Children. Follow the link to get the code you’ll need to add to your page and watch a video tutorial on how to set everything up.

Creating your list of items

First, you’ll need to create the list itself. Create the CMS collection you’ll be using to populate the list and then build it on the frontend however you like and connect it to the CMS collection.

After you’ve created and designed your list, add these attributes to it:

  • ms-code-filter-list=”x”
  • ms-code-visibility-subject=”x”

We’re using “x” as a value just to match the list with the section itself, but you can use whatever value you like (e.g. “favorites” for a Favorites section, “pinned” for a Pinned section, and so on).

Now for the container that houses the entire section that you want to disappear if the list is empty, add the following attribute:

  • ms-code-visibility-target=”x”

Making the conditional visibility work

Now that you’ve got your list and you’ve connected it to a CMS collection, all you need to do is add the MemberScript #25 custom code to your page, before the closing body tag.

This whole thing works by hiding the target (the container with the target attribute) if the subject (the list with the subject attribute) has no children elements or if they’re set to display:none.

Conclusion

That’s it, you can now go and test your disappearing section by adding and removing elements from the list it houses.

To create more disappearing sections on your page, repeat the steps above and just replace the attribute values with something representative of this new section.

If you want to use our demo project to get you started, just click the button below to add it to your Webflow site.

Blog image

Our demo will help you easily filter items out of a list based on the presence of an item within its children – this works perfectly not only for CMS lists, but also static ones and lists generated by member JSON.

Take me to the Scripts

https://www.memberstack.com/scripts/hide-element-based-on-other-elements-children

Written by

Ovidiu

Contributor

Contents

  • Memberscripts needed
  • Tutorial
  • Cloneable
  • Why/Use Cases
  • How to hide an empty section on Webflow
  • Creating your list of items
  • Making the conditional visibility work
  • Conclusion
  • Take me to the Scripts

Share

Explore Memberstack

  • All Features
  • Customer Showcase
  • Templates
  • Find Experts
  • Pricing
  • Help Center

Product

  • Full Feature List
  • User Accounts
  • Gated Content
  • Secure Payments
  • API & Integrations
  • Data Tables
  • Memberstack & Webflow
  • Memberstack & Claude Code
  • Memberstack & WordPress
  • Create a new account
  • 2.0 Log in
  • 1.0 Log in
  • Pricing

Learn about Memberstack

  • Showcase
  • Testimonials
  • Why Memberstack
  • Memberstack vs Outseta
  • Memberstack vs Memberspace
  • Memberstack vs Webflow Memberships

Company

  • About
  • Careers
  • Changelog
  • Partnerships(email)
  • Contact Us(email)
  • X
  • LinkedIn
  • "Do Not Sell My Data" Promise

Resources

  • Vibe Coding
  • Templates
  • Components
  • MemberScripts
  • Data Attributes
  • Find Experts
  • Hiring Guide
  • Webflow Slack Community
  • WordPress Slack Community
  • Support Forum
  • Help Center
  • Blog
  • llms.txt (for AI)
  • llms-full.txt (for AI)
AICPA
SOC

SOC 2 TYPE 1

CERTIFIED

GDPR

COMPLIANT

CCPA

COMPLIANT

Privacy PolicyTerms of ServiceCookie PolicySecurity Policy

© Memberstack Inc. 2018 - 2025. All rights reserved.

Memberstack - The no-code membership platform for any website | Product Hunt