Using videos in your posts, as well as other types of media, will enrich them, which is a very good thing for content marketing, user experience and SEO!
Usually, when you embed a video in your blog post, it will be displayed on the left side, which might look ugly. So, in this article, we’ll give you a tip on how to center a video in WordPress!
For our example, we’ll use YouTube, which is the most common way of adding videos to your posts. It’s always better to embed a video, rather than uploading one!
This tip also applies for other video-sharing websites, like Vimeo, Vine, etc.
How to embed a video in WordPress
First, let’s see how to embed a video in WordPress. The simplest way is to just copy the video’s link (e.g.
https://www.youtube.com/watch?v=pov5VBarQt8 ), paste it in your post’s text editor and WordPress will automatically load it.
Usually, when you use this method, the video will cover the whole width of your content area:
This method won’t work for all video-sharing websites!
If you want the YouTube video to be smaller in size or you want to toggle different options, like “Show player controls”, “Show video title and player actions”, etc., you’ll need to get the Embed code, which looks something like this:
<iframe width="400" height="225" src="https://www.youtube.com/embed/pov5VBarQt8" frameborder="0" allowfullscreen></iframe>
The thing is that after you insert the embed code in your post, your video will most likely appear like this:
As you can see, it’s not centered, thing which leads us to our main topic.
How to center the video
In order to center a video, you’ll need to add a piece of code around the embed part. Don’t worry, it’s simple.
After you added your embed code in your post’s Text (not Visual) editor, you need to wrap this code around it:
<div style="text-align: center"></div>
So it should look something like this (click to enlarge):
After adding that code, our example video should be centered. Let’s check it out:
Yep, it’s centered!
Now that you know how to center a video in WordPress, your content will look more organized and appealing!
Note that if you just paste the video’s link, not the embed code, like I mentioned above, you won’t need to center it anymore, of course, because it will cover the whole width of your post!
Hope you enjoyed our post! If you have any questions or thoughts, please drop a comment!