How to Center a Youtube Video in WordPress

How to Center a Youtube Video in WordPress

2 minutes read


This article is all about learning How to Center a Youtube Video in WordPress.

Would you like to center the videos in WordPress? By default, if your video’s width is less than that of your article field, WordPress will automatically align it to the left, leaving an additional white room on the right. In this post, we’ll see How to Center a Youtube Video in WordPress.

Learn How to Center a Youtube Video in WordPress

Let’s see how quickly you can center a video in WordPress, or expand it, to make your videos look fine.

Center YouTube iframe

Some owners of WordPress have disabled embedders because of their efficiency. So, You may have more power over the iframe code from YouTube.

  • Step 1: To record the Embed code as seen below, Right-click on the Youtube video.
  • Step 2: If you are using Gutenberg Editor (Block Editor), select the “Embed” option.
  • Step 3: Into the WordPress editor, paste the embed code.

The embed code will look like this:

<iframe width="652" height="314" src="" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

It can appear as follows, by default. It isn’t focused, as you can see. You may expand the width. However, you want the width to fit other-oriented images that are not full or full-screen.

  • Step 4: We have to add a DIV and text-align center to center the YouTube embedding (iframe). The updated code below.
<div style="text-align:center;">
/// your video embed code goes here

Center YouTube embed

You’re more likely only to insert the URL of the YouTube video, and it will instantly appear in your post if you’ve been running Block Editor, without any embeds disabled. Follow the steps below if you are unable to see it automatically centered.

  • Step 1: Go to the Customizer in WordPress, which is inside the menu of Appearance >> Customize on your dashboard.
  • Step 2: Navigate to “Additional CSS” and click “Publish” after you enter the following code.
.wp-block-embed-youtube {
margin:0 auto;

And Now preview the changes,

Sum Up

We hope our article on How to Center a Youtube Video in WordPress was helpful. There were many comments on our last article asking for a tutorial about changing passwords in WordPress. So, you may also want to check step by step guide on How to Change Your Password in WordPress.

Video tutorial

If you have any suggestions or queries, do comment and help us improve more.

What do you think?

Leave a Reply

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

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Exit mobile version