# How to display a banner for visitors only?

**URL:** https://meta.discourse.org/t/how-to-display-a-banner-for-visitors-only/87800
**Category:** Support
**Created:** [5월 18, 2018, 4:41오전 UTC](https://meta.discourse.org/t/how-to-display-a-banner-for-visitors-only/87800 "2018-05-18T04:41:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![adrianbblk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adrianbblk/32/87512_2.png) [@adrianbblk](https://meta.discourse.org/u/adrianbblk)
#### Post date: [5월 18, 2018, 4:41오전 UTC](https://meta.discourse.org/t/how-to-display-a-banner-for-visitors-only/87800/1 "2018-05-18T04:41:14Z")

</div>

Hi,

I need to display a banner at the top of the page, but it should be for visitors only. How to set it to disappear for logged users ?

Thanks

---

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [5월 18, 2018, 5:15오전 UTC](https://meta.discourse.org/t/how-to-display-a-banner-for-visitors-only/87800/2 "2018-05-18T05:15:08Z")

</div>

You can make use of the `anon` class added to the `<body>` tag. More on this here:

> [@Banner Topic on home page and only for anonymous users](https://meta.discourse.org/t/banner-topic-on-home-page-and-only-for-anonymous-users/80959/5):
>
> So for example, in your customizations if you add HTML content (Admin \> Customize \> Themes \> Edit HTML/CSS \> Header/After Header/Footer): \<div class="anon-content"\> \<p\>This is test content\</p\> \</div\> You can then add this to your CSS so that content only shows for anon users: .anon-content { display: none; } .anon .anon-content { display: block; } If you wanted to go further and only show that content for anon users on the category page, you could use this CSS: .anon-content …

The selector in your case would be inverted like so:

```plaintext
body:not(.anon) {
	#banner {
		display: none;
	}
}

```

Which effectively hides the banner unless the user is logged out.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [6월 8, 2024, 12:37오후 UTC](https://meta.discourse.org/t/how-to-display-a-banner-for-visitors-only/87800/3 "2024-06-08T12:37:28Z")

</div>

이 주제는 2213일 후 자동으로 닫혔습니다. 더 이상 답변을 할 수 없습니다.
