Whitelisting certain CSS tags in posts

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!!

1 Like

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. :slight_smile:

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

3 Likes

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>

Also check out the [wrap= method:

3 Likes

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.

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

1 Like

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.