How do I center a YouTube video in WordPress?

If you run a WordPress-powered website, you’ve probably wanted to embed a YouTube video at one point or another. Video can add interactivity and excitement to a blog post. Fortunately, WordPress and YouTube make this a very easy process. However, centering your YouTube video can be a bit tricky, especially if you don’t know anything about encoding. However, this article will teach you a very simple solution. It will make sure that you can center any YouTube video, or any object, for that matter.

First you have to include the video in your publication. Go to YouTube, click embed (below the video), choose your options, and copy the HTML code. You then take that code and paste it into the WordPress visual editor. Remember that you have to configure HTML, using the button in the upper right corner. Then just paste your YouTube embed code. Now you have the video on your post or page.

Once you’ve done that, you can go back to the visual tab in the WordPress editor. You will see your video (or object) as a large yellow box. Ideally, you could just click on that box and click the middle button in the editor. Unfortunately, that doesn’t work. I’m not sure why exactly, but it’s probably because the core command in WordPress inserts HTML code that the object doesn’t recognize. For example, even if you went back to the HTML editor and wrapped the object in the tags

it will not work.

However, the solution is quite simple. You just have to navigate back to the HTML part of your editor. You won’t see the yellow box, you will now see the video embed code. Just before the embed code, enter:

</p> <p> style div=&#8221;text-align:center;&#8221; (in html brackets, of course removing spaces around the input symbol)<br />

And then after the end of the embed code:

</p> <p> /div (also in html parentheses)<br />

When you switch back to your visual editor, you’ll notice that the yellow box is centered. Now that you’ve 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. If you’re not comfortable with HTML, write the code above right now. If it’s on your computer, add it to a text file so you can easily copy and paste. Try it out in your next blog post and let me know how it works.