How To Center Youtube Videos in WordPress Posts

how_to_center_youtube_video-onizumarketingIf you run a wordpress powered website you have probably wanted to embed a Youtube video at one time or another. Video can add interactivity and excitement to a blog post. Luckily, WordPress and Youtube make this a very easy process. Centering your Youtube video can be a tricky process though, especially if you don’t know any coding. There is a very simple fix though, that will ensure you can center any youtube video, or any object for that matter.

First you have to get the video into your post. You go to Youtube, click embed (under video), choose your options and copy the code. You then take that code and paste it into the WordPress HTML editor. Remember you have to set to HTML, using the button in top right corner. Then you simply paste in your Youtube embed code. Now you have the video in your post or page.

Once you have that done you can switch back to the visual tab on the WordPress editor. You will see your video (or object) as a large yellow box. Ideally, you could simply click on that box and click the center button on the editor. That doesn’t work. I am not sure exactly why, but it is probably because the center command in WordPress inserts html code that the object doesn’t recognize. Even if you wrap the object yourself in tags it won’t work.

The fix is pretty simple though. You just have to navigate back to the html part of your editor. You won’t see the yellow box now you will see the embed code for the video. Right before the embed code, enter:

div style=”text-algin:center;” (in between html brackets of course)

And then after the end of the embed code:

/div (also in html brackets)

When you switch back to your visual editor you will notice the yellow box is centered! Now that you have learned this code you can center any youtube video or other object in each of your posts. Use it often enough and it won’t be long until you have the code memorized. Try it on your next blog post and let me know how it works.

Subscribe

Subscribe to our e-mail newsletter to receive updates.

Comments are closed.
%d bloggers like this: