Title: Adding margins automatically with CSS
Last modified: August 19, 2016

---

# Adding margins automatically with CSS

 *  [detobey](https://wordpress.org/support/users/detobey/)
 * (@detobey)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/adding-margins-automatically-with-css/)
 * Hi all:
 * What information do I add to my style sheet to always force the following with
   every photo inserted into a blogpost?
 * margin-top: 2px; margin-bottom: 4px; margin-left: 10px; margin-right: 10px;
 * I want those margins to hold true for every image I could ever insert into a 
   blog. I don’t want to have to enter them manually in every post. Can I default
   them via the style sheet?
 * Thanks — detobey

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

 *  [AlethiaPak](https://wordpress.org/support/users/alethiapak/)
 * (@alethiapak)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/adding-margins-automatically-with-css/#post-1302494)
 * `img{ margin:2px 10px 4px 10px;}`
 * img > for every image on your site
    { margin:2px 10px 4px 10px;} > top right 
   bottom left
 * note that you might want to find specific class that wrap or is applied to the
   image you want to work with then do
    `.yourClass img { margin:2px 10px 4px 10px;}`
   or `img.yourClass { margin:2px 10px 4px 10px;}`
 * b/c if you use only
    `img{ margin:2px 10px 4px 10px;}` it will really margin 
   out all image in your site.
 *  [Peter Boosten](https://wordpress.org/support/users/pboosten/)
 * (@pboosten)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/adding-margins-automatically-with-css/#post-1302503)
 * The easiest way (but this is for ALL images – also the header if applicable) 
   would be
 *     ```
       img {
         margin: 2px 10px 4px 10px;
       }
       ```
   
 * or in short hand
 *     ```
       img {
         margin: 2px 10px 4px;
       }
       ```
   
 * Peter

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

The topic ‘Adding margins automatically with CSS’ is closed to new replies.

 * 2 replies
 * 3 participants
 * Last reply from: [Peter Boosten](https://wordpress.org/support/users/pboosten/)
 * Last activity: [16 years, 5 months ago](https://wordpress.org/support/topic/adding-margins-automatically-with-css/#post-1302503)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
