# Whitelisting certain CSS tags in posts

**URL:** <https://meta.discourse.org/t/whitelisting-certain-css-tags-in-posts/152482>\
**Category:** Support\
**Created:** [May 23, 2020, 8:05pm UTC](https://meta.discourse.org/t/whitelisting-certain-css-tags-in-posts/152482 "2020-05-23T20:05:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![wigsie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wigsie/32/174389_2.png) [@wigsie](https://meta.discourse.org/u/wigsie)\
**Post date:** [May 23, 2020, 8:05pm UTC](https://meta.discourse.org/t/whitelisting-certain-css-tags-in-posts/152482/1 "2020-05-23T20:05:52Z")

</div>

I need guidance on the current method to whitelist certain CSS tags in html in posts. I understand there are security concerns in whitelisting certain tags in posts, however, we have a small, controlled user base for this discourse installation.

I’ve read several posts about using plugins and whiteListTag, but these posts were old, and I’m wondering if this is still the preferred method for accomplishing this.

Also, does anyone have any examples of how to do this?

Thank you in advance for any help you can provide. Much appreciated!!

---

<div class="post-metadata">

**Author:** ![maiki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maiki/32/233950_2.png) [@maiki](https://meta.discourse.org/u/maiki)\
**Post date:** [May 23, 2020, 9:00pm UTC](https://meta.discourse.org/t/whitelisting-certain-css-tags-in-posts/152482/2 "2020-05-23T21:00:12Z")

</div>

Hiya! Could you share an example of what you are trying to add to a post? I don’t know exactly what a CSS tag is. 🙂

CSS can be added to the entire site, and can use selectors to select specific elements, maybe that’s what you are looking for?

---

<div class="post-metadata">

**Author:** ![wigsie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wigsie/32/174389_2.png) [@wigsie](https://meta.discourse.org/u/wigsie)\
**Post date:** [May 25, 2020, 8:54pm UTC](https://meta.discourse.org/t/whitelisting-certain-css-tags-in-posts/152482/3 "2020-05-25T20:54:05Z")

</div>

Thanks for your response. See below for an example. This is text from a post. I’m trying to add CSS to posts, but the classes get stripped out. I’ve examined using \<div data-theme-\*\>, but it’s not robust enough for our needs. I know you can do custom theming, but we need people to be able to add CSS to posts. I’ve read about using a plugin and whiteListTab may be a solution.

Any help or examples you could provide would be much appreciated.

Barbara

```
<table class="ptTable">
  <tr>
     <th class="ptCol1"><strong>Platform</strong></th>
     <th><strong><div data-theme-ptCol2>Description</div></strong></th>
     <th class="ptCol3"><strong>Features</strong></th>
     <th class="ptCol4"><strong>How to Get Started </strong></th>
     <th class="ptCol5"><strong>Get Support</strong></th>
     <th class="ptCol6"><strong>Existing User?</strong></th>
  </tr>
  <tr>

```

---

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [May 25, 2020, 9:31pm UTC](https://meta.discourse.org/t/whitelisting-certain-css-tags-in-posts/152482/4 "2020-05-25T21:31:21Z")

</div>

Also check out the `[wrap=` method:

> [@Generic bbcode wrapper for theme components](https://meta.discourse.org/t/generic-bbcode-wrapper-for-theme-components/123516):
>
> I added this feature a while back and realised I didn’t post about it. You can now use a special syntax in markdown to have it cooked and usable in theme components without having to write a plugin. // wrapped in div.d-wrap [wrap=baz foo=bar]Content[/wrap] // wrapped in div.d-wrap [wrap=baz foo=bar] Content [/wrap] // wrapped in div.d-wrap [wrap=baz foo=bar] [/wrap] // this one will be rendered as a span.d-wrap instead of a div.d-wrap a [wrap=baz]Content[/wrap] b The name of the component w…

---

<div class="post-metadata">

**Author:** ![wigsie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wigsie/32/174389_2.png) [@wigsie](https://meta.discourse.org/u/wigsie)\
**Post date:** [May 26, 2020, 5:49pm UTC](https://meta.discourse.org/t/whitelisting-certain-css-tags-in-posts/152482/5 "2020-05-26T17:49:56Z")

</div>

Thanks for your reply. This [wrap] method seems to work well for adding `<div>` or `<span>` tags around text, but I don’t see how it can be used to add `<div>` or `<span>` tags around elements in a table.

Let me know if I’m missing anything. We need to be able to style tables.

---

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [May 26, 2020, 6:06pm UTC](https://meta.discourse.org/t/whitelisting-certain-css-tags-in-posts/152482/6 "2020-05-26T18:06:10Z")

</div>

You should be able to wrap the entire table in one, and apply the styling in the handler.

---

<div class="post-metadata">

**Author:** ![wigsie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wigsie/32/174389_2.png) [@wigsie](https://meta.discourse.org/u/wigsie)\
**Post date:** [May 26, 2020, 7:45pm UTC](https://meta.discourse.org/t/whitelisting-certain-css-tags-in-posts/152482/7 "2020-05-26T19:45:59Z")

</div>

Thanks so much for your feedback. However, ideally, we want to add custom CSS to HTML rather than mark-up. If anyone has any info about whiteListTag, or any similar functionality, it would be much appreciated.
