# Adding custom class to img tag

**URL:** <https://meta.discourse.org/t/adding-custom-class-to-img-tag/21425>\
**Category:** Feature\
**Created:** [22 Outubro , 2014 17:06 UTC](https://meta.discourse.org/t/adding-custom-class-to-img-tag/21425 "2014-10-22T17:06:10Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![mpteng](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpteng/32/108099_2.png) [@mpteng](https://meta.discourse.org/u/mpteng)\
**Post date:** [22 Outubro , 2014 17:06 UTC](https://meta.discourse.org/t/adding-custom-class-to-img-tag/21425/1 "2014-10-22T17:06:10Z")

</div>

Continuing the discussion from [Suggestion: borders for images](https://meta.discourse.org/t/suggestion-borders-for-images/4224/16):

> [@ampburner](#):
>
> completely agree with @Vilx
> 
> This is not about styling.  
> when you post a (partially white) image in a post with a white background - the image becomes visually indistinguishable from the discussion.
> 
> An example:  
> \<img src=“[//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/1/2/12d989f3eb62252a244e170ef6f9b9e4288c5c63.JPG](https://global.discourse-cdn.com/meta/original/3X/1/2/12d989f3eb62252a244e170ef6f9b9e4288c5c63.JPG)” width=“508” height=“68”\>
> 
> I’m going to see if I can change this in my own Discourse install’s css - but I think it should be part of the default css.

Is there a way to add a class to the img tag that would then allow me to easily add this optionally? For example, if I could do something like:  
\<img src=“[//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/1/2/12d989f3eb62252a244e170ef6f9b9e4288c5c63.JPG](https://global.discourse-cdn.com/meta/original/3X/1/2/12d989f3eb62252a244e170ef6f9b9e4288c5c63.JPG)” width=“508” height=“68” class=“borderon”\>

Then I could be able to really easily add the custom CSS to add borders just to that class.

---

_[View the full topic](https://meta.discourse.org/t/adding-custom-class-to-img-tag/21425)._
