# CSS class on Body tag to distinguish homepage / non-category page

**URL:** https://meta.discourse.org/t/css-class-on-body-tag-to-distinguish-homepage-non-category-page/51201
**Category:** Feature
**Created:** [October 7, 2016, 12:15am UTC](https://meta.discourse.org/t/css-class-on-body-tag-to-distinguish-homepage-non-category-page/51201 "2016-10-07T00:15:01Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![charleswalter](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/charleswalter/32/116433_2.png) [@charleswalter](https://meta.discourse.org/u/charleswalter)
#### Post date: [October 7, 2016, 12:15am UTC](https://meta.discourse.org/t/css-class-on-body-tag-to-distinguish-homepage-non-category-page/51201/1 "2016-10-07T00:15:01Z")

</div>

I had mentioned this in another topic, but thought I’d be more direct 😊

Could a class be added to the body tag of the homepage (and perhaps to all non-category pages)? I couldnt figure out how to target CSS only to be applied to the homepage or non category pages

ie BODY class=latesthome global

(If no category identified, the global class gets added)

Its particularly useful for backgrounds. Categories of course have the baked in background feature, but to apply backgrounds for other screens, we depend on css. It also means for inner pages, we are loading our global background unnecessarily.

Perhaps there’s already some way of achieving what I’m describing, in a cleaner way?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 7, 2016, 2:00am UTC](https://meta.discourse.org/t/css-class-on-body-tag-to-distinguish-homepage-non-category-page/51201/2 "2016-10-07T02:00:21Z")

</div>

I believe @techapj worked on something related to this recently.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [October 7, 2016, 2:47am UTC](https://meta.discourse.org/t/css-class-on-body-tag-to-distinguish-homepage-non-category-page/51201/3 "2016-10-07T02:47:54Z")

</div>

> [@charleswalter](#):
>
> perhaps to all non-category pages

This was recently done via:

[https://github.com/discourse/discourse/commit/72f93699667b5695b13338ebe580acc75b8fd301](https://github.com/discourse/discourse/commit/72f93699667b5695b13338ebe580acc75b8fd301)

> [@charleswalter](#):
>
> I couldnt figure out how to target CSS only to be applied to the homepage or non category pages

Currently there is no identifier (unique class) for `/latest`, `/new`, `/unread` & `/top` pages. I will add that and notify here.

---

<div class="post-metadata">

### Author: ![charleswalter](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/charleswalter/32/116433_2.png) [@charleswalter](https://meta.discourse.org/u/charleswalter)
#### Post date: [October 7, 2016, 3:38am UTC](https://meta.discourse.org/t/css-class-on-body-tag-to-distinguish-homepage-non-category-page/51201/4 "2016-10-07T03:38:11Z")

</div>

Very cool @techAPJ. What do you think of the suggesting of adding a catch all “global” class as well, when there is no category defined. This can be an easy way to set a background (for example) for all pages that don’t belong to a category, without having to identify every single one .

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [October 7, 2016, 4:32am UTC](https://meta.discourse.org/t/css-class-on-body-tag-to-distinguish-homepage-non-category-page/51201/5 "2016-10-07T04:32:04Z")

</div>

> [@charleswalter](#):
>
> What do you think of the suggesting of adding a catch all “global” class as well, when there is no category defined

I don’t think there would be that many of them where using a comma separated list would be that much trouble.

But a “global” class would be easier.

If it’s going to be done I guess now while that area of code is being worked on would be the opportune time to do it.

Think as I might, ATM the best I can come up with as a descriptive value is “non-category”. It just feels to me that there should be _something, anything_ better than that, but I got nothing.

---

<div class="post-metadata">

### Author: ![charleswalter](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/charleswalter/32/116433_2.png) [@charleswalter](https://meta.discourse.org/u/charleswalter)
#### Post date: [October 7, 2016, 5:03am UTC](https://meta.discourse.org/t/css-class-on-body-tag-to-distinguish-homepage-non-category-page/51201/6 "2016-10-07T05:03:18Z")

</div>

Thx for considering the suggestion. Other ideas for the class name. I am ultimately indifferent 😉  
no-category  
category0  
general  
site-main  
core

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [October 10, 2016, 6:03pm UTC](https://meta.discourse.org/t/css-class-on-body-tag-to-distinguish-homepage-non-category-page/51201/7 "2016-10-10T18:03:17Z")

</div>

> [@techAPJ](#):
>
> Currently there is no identifier (unique class) for /latest, /new, /unread & /top pages.

Added `navigation-topics` class to above mentioned pages (via [this commit](https://github.com/discourse/discourse/commit/d06c82e5559715eb569c52cffff1d235c6d30e84)).

> [@charleswalter](#):
>
> What do you think of the suggesting of adding a catch all “global” class as well, when there is no category defined.

This will be tricky to implement. The better solution IMO is to assign a unique class to a page (or set of pages).

---

<div class="post-metadata">

### Author: ![charleswalter](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/charleswalter/32/116433_2.png) [@charleswalter](https://meta.discourse.org/u/charleswalter)
#### Post date: [October 10, 2016, 7:18pm UTC](https://meta.discourse.org/t/css-class-on-body-tag-to-distinguish-homepage-non-category-page/51201/8 "2016-10-10T19:18:20Z")

</div>

Thx @techAPJ!

I mentioned the no-category class, thinking that the DFP plugin has a unique variable of 0 that it uses for all pages that don’t have an associated category. So I assumed that the same logic could be applied.

---

<div class="post-metadata">

### Author: ![davidkingham](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidkingham/32/119528_2.png) [@davidkingham](https://meta.discourse.org/u/davidkingham)
#### Post date: [July 31, 2022, 7:53pm UTC](https://meta.discourse.org/t/css-class-on-body-tag-to-distinguish-homepage-non-category-page/51201/9 "2022-07-31T19:53:21Z")

</div>

> [@techAPJ](#):
>
> Added `navigation-topics` class to above mentioned pages (via [this commit](https://github.com/discourse/discourse/commit/d06c82e5559715eb569c52cffff1d235c6d30e84)).

Sorry to revive an ancient topic, but does this class still exist? I can’t seem to find a CSS selector for /latest /top, etc. Thanks!

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [July 31, 2022, 8:26pm UTC](https://meta.discourse.org/t/css-class-on-body-tag-to-distinguish-homepage-non-category-page/51201/10 "2022-07-31T20:26:59Z")

</div>

Hi David,

Yes, `.navigation-topics` is a `body` class and still available. 🙂

 ![Screenshot 2022-07-31 at 22.22.25](https://global.discourse-cdn.com/meta/original/4X/f/6/0/f60c1e0528e314f1f669e4c4e2c68a3f1aeeaae8.png)
