# Default theme discards CSS class for img tags. What now?

**URL:** https://meta.discourse.org/t/default-theme-discards-css-class-for-img-tags-what-now/258525
**Category:** Support
**Tags:** css
**Created:** [March 17, 2023, 2:59pm UTC](https://meta.discourse.org/t/default-theme-discards-css-class-for-img-tags-what-now/258525 "2023-03-17T14:59:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jbrains](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jbrains/32/208183_2.png) [@jbrains](https://meta.discourse.org/u/jbrains)
#### Post date: [March 17, 2023, 2:59pm UTC](https://meta.discourse.org/t/default-theme-discards-css-class-for-img-tags-what-now/258525/1 "2023-03-17T14:59:17Z")

</div>

I created a post containing `<img class="xyz" src="..." />`, but when Discourse renders the post, it puts my image in a `lightbox-wrapper` and discards my CSS class, so I can’t style it using that class.

Is this a defect in the theme? in Discourse? Is it just something I need to make peace with not being allowed to do? I only want to style certain kinds of images in this particular way and I prefer not to write custom CSS that depends on CSS classes whose names I don’t control.

Thanks.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [March 17, 2023, 3:13pm UTC](https://meta.discourse.org/t/default-theme-discards-css-class-for-img-tags-what-now/258525/2 "2023-03-17T15:13:39Z")

</div>

> [@jbrains](#):
>
> Is this a defect in the theme? in Discourse?

Hi @jbrains 🙂

Discourse only accepts an array of allowed HTML tags and attributes. Adding an arbitrary class to an element isn’t possible without creating a plugin.

However, if you want to customize an image inside your post, you can put it inside a `[wrap]` tag or something similar.

Have a look at [Customize posts' contents with your own styles](https://meta.discourse.org/t/customize-posts-contents-with-your-own-styles/257738)

---

<div class="post-metadata">

### Author: ![jbrains](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jbrains/32/208183_2.png) [@jbrains](https://meta.discourse.org/u/jbrains)
#### Post date: [March 20, 2023, 3:54pm UTC](https://meta.discourse.org/t/default-theme-discards-css-class-for-img-tags-what-now/258525/3 "2023-03-20T15:54:51Z")

</div>

I understand and I did something that I can be satisfied with. Thank you.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [April 29, 2023, 1:22pm UTC](https://meta.discourse.org/t/default-theme-discards-css-class-for-img-tags-what-now/258525/4 "2023-04-29T13:22:00Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
