Centering images in Tumblr

When you add an image in your tumblog one of the options to align it is “middle”. Those who know HTML will know that this align attribute has been depreciated, but the “middle” declaration is for centering vertically not horizontally. The user in question wanted just the images, not the text to be centered, and I wanted to try and achieve this without forcing them to edit classes or anything complicated. You might have thought that adding this to the CSS this would do the job:

p img {margin: 0 auto;}

but also no. Images are inline elements so they don’t understand the margin. However this will fix that:

p img {display:block;margin: 0 auto;}

Hope this helps someone!

One thought on “Centering images in Tumblr

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s