Anyway to style discourse topic title? ( IE, red, bold, highlight, anything. )

AI-generated summary

The discussion explores styling topic titles in Discourse, such as changing color, bolding, or highlighting. plosprawrs asks how to make topic titles stand out using CSS. Johani explains that category and tag-specific styles can be applied by targeting CSS selectors based on the topic’s category or tags. In the topic list, the <tr> element includes classes like category-meta or tag-automotive, while on topic pages, the <body> tag includes similar classes. This allows for targeted styling. For more details, a guide on adding CSS to Discourse is referenced here.

For example in the body I am given markdown/HTML/etc capability. Does anyone know a way to bring attention to the topic title? ( IE color, bold, styling etc. )

Kind Regards

2 likes

You can target your CSS based on a specific tag or category.

There are two areas where you can add category / tag specific styles to topics.

  1. In the topic list

    We add both the topic’s category and its tags to the <tr> element that contains that item. So, a topic in the #meta category that has the tags automotive and machines will look like this in your browser inspection tools

    HTML tree view of the TR element discussed above

    if you want to target it based on the category, you would use tr.category-meta as your selector. If you want to target it based on the tag automotive, you would use tr.tag-automotive and so on.

  2. On topic pages

    We also do the same here. We add the relevant category and tag classes on topic pages. The only difference is that we add them to <body> tag instead. So, it looks like this

    HTML tree view of the Body element discussed above

You can read more about how to add CSS to your Discourse site here

3 likes