How To Center Things In WordPress And Make It Stick

Center Things In Wordpress

This Works In WordPress And Anything HTML

This is a nice simple technical tip on how to center things in WordPress and keep them centered. It will work with anything HTML but is particularly useful in WordPress as when you center things in WordPress the editor strips the centering out sometimes.

For example, if you embed a Youtube video and try centering it, the editor will often strip the centering out. You can try saving it from the text/HTML tab but it’s a hit and miss business. It also depends on what version of WordPress and which editor that you are using but here’s a very simple way to add centering that almost always works, the WordPress editor doesn’t strip it out, well it’s worked up to now 🙂

Let’s say you do want to embed a YouTube video and then center it. You would typically select the Text/HTML tab in the post or page editor which looks like this:

Visual-HTML - center things

Then you would find the place you want to put it and copy and paste the embed code from YouTube like this:

<iframe width=”480″ height=”360″ src=”//″ frameborder=”0″ allowfullscreen></iframe>

Then yCenter iconou go back to Visual mode, click the video place holder and click the center align icon. Often but not always the video stays where it is or maybe it centers but when you save and preview it, it’s gone back to the left. The WordPress editor does some odd and frustrating things sometimes doesn’t it?

Center Div Align

Ok, here’s what so far seems to work for me. The WordPress editor likes the “div” HTML tag and whatever you do with that tag it seems to leave alone so I use that and it works with just about any block or text, code etc. You need to be in text/HTML mode and then do this as highlighted in yellow:

<div align=”center“>

<iframe width=”480″ height=”360″ src=”//″ frameborder=”0″ allowfullscreen></iframe> 


Simple but effective!

I hope that’s useful to you and if you would like to know about my future posts you can sign up to my once a week list below if you want, if you are on this list you won’t get promotional emails unless I am personally recommending something and even then it will be a gentle promotion. You will get notified of my blog posts in my newsletter type broadcasts which I normally email out once or twice a week.

[sc:Sub1AWeek ] [sc:MySig]

How To Center Things In WordPress And Make It Stick


One comment

Leave a Reply

Your email address will not be published. Required fields are marked *