Title: Default CSS class for image in post
Last modified: August 19, 2016

---

# Default CSS class for image in post

 *  [Christopher](https://wordpress.org/support/users/freestylemedia/)
 * (@freestylemedia)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/default-css-for-image-in-post/)
 * Hi.
 * Is it possible, for when you insert an image into a post, to automatically assign
   it a CSS class? Would just seem a little simpler than inserting the image, closing
   the media uploader, clicking on the image proper then navigating to advanced 
   settings to change the class.
 * The reason being is I want to apply some custom CSS formatting to certain images
   in posts.
 * I imagine I would have to do this via the functions.php template (correct me 
   if I’m wrong), but I’m not sure where to go after that. If anyone has any tips
   and/or solutions that would be great!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [DigitalSquid](https://wordpress.org/support/users/twelvefootsnowman/)
 * (@twelvefootsnowman)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/default-css-for-image-in-post/#post-1619046)
 * Each post gets it’s own class automatically – eg: `postid-1`, `postid-2`, etc…
 * So if you know the post ID and there’s only one image in the post you could use`.
   postid-1 img` to select it with CSS.
 *  Thread Starter [Christopher](https://wordpress.org/support/users/freestylemedia/)
 * (@freestylemedia)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/default-css-for-image-in-post/#post-1619095)
 * I was just about to say I want it for all posts (as it’s a photo gallery), but
   then I’ve just thought that I can give all posts the same class and go from there!
 * Well, hopefully, anyway :p
 *  [Lou Sparx](https://wordpress.org/support/users/roulettered/)
 * (@roulettered)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/default-css-for-image-in-post/#post-1619135)
 * Hi,
 * Find out what your posts are wrapped in (should be **content** or something similar)
   Then maybe….
 * ./#content **img** {
    >YOUR STYLE< }
 * Let me know if it worked please or post the url (not sure if wordpress allows
   this) and I’ll have a look.
 * Lou
 * **\*\*EDIT\*\***
    Just noticed you didn’t want the class for ALL images so just
   define a div class with styling in your stylesheet and then wrap each picture
   in the that div class individualy.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Default CSS class for image in post’ is closed to new replies.

 * 3 replies
 * 3 participants
 * Last reply from: [Lou Sparx](https://wordpress.org/support/users/roulettered/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/default-css-for-image-in-post/#post-1619135)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
