How to Align a WordPress Video in the Middle of the Page

Last updated on by admin

Are you using the WordPress video shortcode to embed self-hosted videos into your website? Are you trying to position a video in the middle instead of it being aligned to the left by default? Today I will show you a simple tweak to center your videos with some custom CSS.

WordPress video feature allows you to embed video files by directly inserting the URLs or using a simple Shortcode. For example:

WordPress video embed with a shortcode or URL

When a video file is embedded it’s aligned to the left by default.

WordPress video aligned to the left

In order to align it in the middle you can apply this tweak,

1. Install the Simple Custom CSS plugin.

2. Add this CSS under “Appearance -> Custom CSS“.


.wp-video {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

After applying this CSS, all the videos will be automatically aligned in the middle.

WordPress video aligned in the middle

GET 60% OFF WordPress Hosting Here

2 thoughts on “How to Align a WordPress Video in the Middle of the Page”

  1. Hello!

    I’m wondering how you would go about adding css to only one video on a certain page, Instead of creating the css that edits all the instances of “.wp-video” ???

    1. @Laura, WordPress doesn’t seem to have a unique class for each video instance. So I’m not sure if you can target a specific video with CSS. You can probably place the video inside a custom div and target that div with CSS? For example:

      Text Editor:

      <div class="my-wp-video1">
      video/video shortcode
      </div>
      

      CSS:

      .my-wp-video1 .wp-video {
          text-align: center;
          margin-left: auto;
          margin-right: auto;
      }
      

Leave a Reply

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