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=”//www.youtube.com/embed/LWHlQBHmz9A?rel=0″ 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=”//www.youtube.com/embed/LWHlQBHmz9A?rel=0″ frameborder=”0″ allowfullscreen></iframe> 

</div>

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.

Sign up to my "1 A Week" list
for techy tips, resources,
freebies and other useful stuff.


Stuart

Thanks for reading this far.
www.stuartchalmers.com

Please like my Facebook Fan Page www.facebook.com/StuartChalmersNormalGuy
Facebook Stuart Chalmers Friend me on Facebook or just check me out
Twitter Stuart Chalmers Follow me on Twitter
Google+ Stuart Chalmers Add me to a Google+ circle or just check me out
Skype Stuart Chalmers Skype me at stuart.chalmers

How To Center Things In WordPress And Make It Stick

· 

One comment

Leave a Reply to Janice Bowles Cancel reply

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