HOW TO: Hide web part when it's empty

%3CLINGO-SUB%20id%3D%22lingo-sub-2771024%22%20slang%3D%22en-US%22%3EHOW%20TO%3A%20Hide%20web%20part%20when%20it's%20empty%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2771024%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20web%20part%20I%20wrote%20that%20I%20want%20to%20hide%20when%20there%20is%20no%20content%20in%20it%20(like%20the%20News%20web%20part).%20How%20do%20I%20do%20that%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2771024%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EHide%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWeb%20Parts%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2773750%22%20slang%3D%22en-US%22%3ERe%3A%20HOW%20TO%3A%20Hide%20web%20part%20when%20it's%20empty%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2773750%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F288947%22%20target%3D%22_blank%22%3E%40smithme%3C%2FA%3E%26nbsp%3BThere's%20usually%20an%20option%20to%20hide%20the%20web%20part%20if%20there's%20nothing%20to%20show.%20It's%20definitely%20on%20'News'%2C%20although%20maybe%20not%20on%20every%20web%20part.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22shinypurple_0-1632312508144.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F312031i57483DF1BABB1DF2%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22shinypurple_0-1632312508144.png%22%20alt%3D%22shinypurple_0-1632312508144.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

I have a web part I wrote that I want to hide when there is no content in it (like the News web part). How do I do that?

2 Replies

@smithme There's usually an option to hide the web part if there's nothing to show. It's definitely on 'News', although maybe not on every web part.

 

shinypurple_0-1632312508144.png

 

Sorry, I wasn't more clear. I am writing a custom webpart. I want it to take up zero vertical space on the page when it is empty. How do I programmatically, tell my webpart to display:none;