Posted on

If you run a website with WordPress, you’ve probably wanted to embed a YouTube video at one point or another. Video can add interactivity and emotion 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 any code. 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 put the video in your post. You go to YouTube, click embed (below the video), choose your options and copy the HTML code. Then, take that code and paste it into the WordPress visual editor. Remember to configure it in HTML, using the button in the upper right corner. Then just paste your YouTube embed code. You now 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 big yellow box. Ideally, you can just click on that box and click the middle button of the editor. Unfortunately, that doesn’t work. I’m not sure exactly why, but it’s probably because the core command in WordPress inserts HTML code that the object doesn’t recognize. For example, even if you switch back to the HTML editor and wrap the object in < center > tags, it won’t work.

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

div style = &#8220;text-align: center;&#8221; (in brackets html, of course, removing spaces around the enter symbol)

And then after the end of the embed code:

/ div (also in html brackets)

When you return to your visual editor, you will notice that 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’ve memorized the code. If you are 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. Give it a try in your next blog post and let me know how it works.

Leave a Reply

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