Dev.to WebDev 🛠 Dev 👁 0 📖 10 min read

How to Fix Black Bars and Cropped YouTube Shorts on Mobile Websites

Embedding a YouTube Short on your website should be straightforward. However, the same video that looks perfectly fine on YouTube can appear with black bars, cropped captions, or distorted proportions when viewed on a mo

How to Fix Black Bars and Cropped YouTube Shorts on Mobile Websites

Embedding a YouTube Short on your website should be straightforward. However, the same video that looks perfectly fine on YouTube can appear with black bars, cropped captions, or distorted proportions when viewed on a mobile website.

In most cases, the problem is not the YouTube Short itself. It is how your website handles the video player, aspect ratio, and surrounding container.

The quickest way to fix black bars and cropped YouTube Shorts is to match the embed container to the original video's aspect ratio, remove conflicting CSS properties, and make the iframe responsive.

This guide explains how to identify the cause and fix it without compromising your website's mobile layout.

website's mobile layout

Why YouTube Shorts Show Black Bars or Get Cropped on Mobile Websites

Most traditional YouTube embeds are designed around a 16:9 landscape layout, whereas vertical YouTube Shorts typically use a 9:16 portrait format.

When a vertical video is placed inside a landscape container, the player may introduce empty space around the video to preserve its original proportions. If the website forces the video player to fill an incompatible container, parts of the player or video may become clipped.

Other common causes include:

  • Fixed iframe width and height that do not adjust to smaller screens.

  • WordPress themes or page builders applying a landscape aspect ratio.

  • CSS properties that force the player to scale or hide overflowing content.

  • Parent containers that restrict the height of the video player.

  • Black bars already present in the original uploaded video.

It is important to determine whether the issue originates from the video, YouTube player, or website layout before making changes.

Display issue Likely cause
Black bars on either side Landscape embed container
Black bars above and below Container and video ratio mismatch
Captions or faces cut off Clipping or forced scaling
Video extends beyond the screen Fixed iframe width
Video looks unusually small Incorrect player dimensions
Issue appears only on mobile Responsive CSS conflict

How to Fix Black Bars and Cropped YouTube Shorts on Mobile Websites

Before modifying your website's code, open the affected Short directly on YouTube. If it plays correctly there but displays incorrectly on your website, start by inspecting your embed settings.

1. Set the Correct Aspect Ratio for Your YouTube Shorts

One of the most common reasons for black bars is embedding a portrait video inside a landscape player.

For example, a YouTube Short recorded at 1080 × 1920 pixels will appear considerably smaller when placed inside a standard 560 × 315 pixel iframe. The player has to accommodate the entire vertical video within a much shorter display area.

YouTube Short recorded at 1080 × 1920 pixels

Aspect ratio comparison: A vertical YouTube Short inside landscape and portrait embed containers.

For vertical YouTube Shorts, use a 9:16 aspect ratio. However, if your original Short is square, a 1:1 container may be more appropriate. YouTube supports both vertical and square Shorts.

YouTube Help

Use the following dimensions as a reference:

Video format Width Height Aspect ratio
Standard YouTube video 1920 px 1080 px 16:9
Vertical YouTube Short 1080 px 1920 px 9:16
Square YouTube Short 1080 px 1080 px 1:1
Mobile portrait embed 360 px 640 px 9:16
Smaller portrait embed 270 px 480 px 9:16

You do not need to display a video at its original resolution. You simply need to maintain its proportions as the available screen width changes.

2. Make the YouTube Shorts Embed Responsive With CSS

A fixed-width iframe might work perfectly on a desktop website but extend beyond the available space on a smartphone.

Instead of manually assigning different dimensions for every device, use a responsive container that automatically calculates the player height based on its available width.

Replace your existing embed with the following HTML:

<div class="youtube-short">
  <iframe
    src="https://www.youtube.com/embed/VIDEO_ID"
    title="YouTube Short"
    loading="lazy"
    allowfullscreen>
  </iframe>
</div>

Replace VIDEO_ID with the ID of your YouTube Short.

Next, add the following CSS to your website:

.youtube-short {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 9 / 16;
  margin: 0 auto;
}

.youtube-short iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

Here is what this code does:

  • width: 100% allows the container to adjust to the available space.

  • max-width: 360px prevents the player from becoming excessively wide on larger screens.

  • aspect-ratio: 9 / 16 maintains the portrait proportions.

  • margin: 0 auto centers the video within its surrounding section.

  • height: 100% allows the iframe to occupy the calculated container height.

Responsive portrait embeds maintain consistent proportions across different mobile viewport sizes.

portrait embeds maintain consistent proportions across different mobile viewport sizes

You can increase or decrease the maximum width depending on your website's layout. For square Shorts, change the aspect ratio to 1 / 1.

YouTube requires embedded players to have a viewport of at least 200 × 200 pixels. If your mobile layout contains narrow columns, consider displaying the Short in a single-column section instead.

Google for Developers

3. Remove Fixed Width, Height, and Clipping Styles

Sometimes, changing the aspect ratio is not enough. Your website theme or page builder may still apply CSS that overrides your updated settings.

This is particularly common when a website uses the same video container for both regular YouTube videos and Shorts.

Open your website in Chrome, right-click the affected video, and select Inspect. Check the iframe and its parent containers for properties such as:

height: 200px;
width: 560px;
aspect-ratio: 16 / 9;
padding-bottom: 56.25%;
overflow: hidden;
transform: scale(1.5);

These properties are not necessarily incorrect, but they can interfere with a responsive portrait video layout.

responsive portrait video layout
Use browser developer tools to inspect the iframe and its surrounding container.

For example, padding-bottom: 56.25% is commonly used to maintain a 16:9 video container. When applied to a vertical Short, it creates insufficient height for the intended portrait layout.

Similarly, overflow: hidden can hide parts of an oversized iframe, including its playback controls, while a scaling transformation can push the player beyond the visible container.

Remove or override the conflicting properties specifically for your Shorts container rather than changing the CSS for every video on your website.

Avoid using object-fit: cover directly on a YouTube iframe. Although this property works with images and native HTML video elements, it does not control the video inside an embedded YouTube player.

4. Check for Black Bars in the Original Video

Not every black bar is caused by your website.

Some videos are edited in landscape format before being uploaded to YouTube, with black backgrounds added around the vertical footage. In these cases, the black bars become part of the video itself.

 black bars become part of the video itself
The difference between player-generated padding and black bars encoded into the original footage.

To identify whether this is the problem:

  1. Open the original video file in a media player or video editor.

  2. Check whether black bars are part of the footage.

  3. Inspect the video's original resolution.

  4. Compare it with the embedded version on your website.

If the black bars are part of the original video file, modifying the iframe will not remove them.

You will need to edit the original footage, export it in the correct portrait format, and upload the corrected version to YouTube.

YouTube may also introduce padding under certain playback conditions, even when the video has the correct dimensions. A completely borderless player cannot be guaranteed on every device.

How to Fix YouTube Shorts Display Issues on Different Website Platforms

Website builders handle embedded videos differently. A solution that works on a custom HTML website may require additional adjustments on WordPress, Shopify, or Wix.

WordPress and Elementor

WordPress themes often apply responsive styling automatically to embedded videos. While this works well for standard YouTube content, the same styling can create unwanted black bars around portrait Shorts.

If you use the WordPress block editor, try replacing the default YouTube block with a Custom HTML block containing the responsive embed code provided earlier.

Add the CSS through your theme's custom CSS settings or stylesheet.

theme's custom CSS settings
Check the video widget's aspect ratio settings in Elementor.

If you use Elementor:

  • Open the affected Video widget.

  • Navigate to its Style settings.

  • Check whether the aspect ratio is set to 16:9.

  • Select 9:16 or a suitable custom ratio if available.

  • Review the parent container's height and overflow settings.

  • Preview and test the published page on mobile.

If the available aspect ratio settings do not meet your requirements, use Elementor's HTML widget with a custom responsive iframe.

For websites displaying several videos, a dedicated WordPress YouTube widget can reduce the need to configure individual embeds.

Shopify

Shopify themes frequently use landscape video sections for promotional videos and product demonstrations.

When YouTube Shorts are added to these sections, the theme's existing video wrapper may continue to enforce landscape proportions.

Inspect the video section for fixed-height settings, landscape aspect ratios, or CSS applied to the iframe's parent element.

If your theme supports Custom Liquid sections, you can use one to add a responsive portrait iframe with section-specific CSS.

For product pages, make sure the embedded Short does not extend beyond the product information column or introduce horizontal scrolling on smaller devices.

Wix and Squarespace

On Wix, the outer HTML embed element can restrict the available space, even when the iframe inside it is responsive.

Open your mobile editor and check whether the embed element is tall enough to accommodate the portrait video. Adjust its dimensions and remove fixed pixel values from the iframe where necessary.

On Squarespace, check whether the existing video block or section supports the required portrait proportions. If it continues to force a landscape layout, consider using an Embed block with a responsive video container.

In both cases, test the published website rather than relying exclusively on the editor preview.

How to Display Multiple YouTube Shorts Responsively With Taggbox

Fixing the aspect ratio of a single YouTube Short is relatively straightforward. The challenge becomes more noticeable when a website displays several Shorts across different pages.

For instance, a brand might want to showcase customer testimonials, product demonstrations, and short tutorials together. Maintaining separate iframe dimensions and CSS rules for every video can make the layout difficult to manage.

Instead of handling each video individually, you can use the Taggbox YouTube feed widget to organize your Shorts within a customizable, responsive video feed.

responsive video feed
Display multiple YouTube Shorts within a unified website video feed.

With Taggbox, you can:

  • Collect YouTube Shorts from supported content sources.

  • Manage and moderate the videos displayed on your website.

  • Customize the feed layout to match your website design.

  • Display multiple videos without maintaining separate iframe embeds.

  • Preview your widget before publishing it.

  • Automatically refresh collected content according to supported update intervals.

To get started, connect YouTube as a content source in Taggbox, collect your Shorts, customize the widget layout, and publish it using the generated embed code.

For detailed implementation instructions, follow this guide on how to embed YouTube Shorts on your website.

When choosing a widget theme, check both thumbnail proportions and the video playback experience. A responsive layout can simplify feed management, but it cannot remove black bars encoded into the original video or override every aspect of YouTube's native player.

Display your YouTube Shorts in a responsive video feed with Taggbox.

Mobile Testing Checklist for Embedded YouTube Shorts

After implementing the fixes, test the videos across multiple screen sizes. A layout that works on a larger smartphone may still cause issues on a smaller device.

test the videos across multiple screen sizes
Use responsive device testing to identify layout issues across different mobile screen sizes.

Before publishing, make sure:

  • Videos display correctly at 320px, 375px, 390px, and 430px viewport widths.

  • Portrait videos maintain their original proportions.

  • Faces, captions, and important visual elements remain visible.

  • Playback controls and fullscreen options are accessible.

  • The video does not introduce horizontal scrolling.

  • Videos work on iPhone Safari and Android Chrome.

  • The surrounding page layout remains stable when the video loads.

  • The published page displays correctly in both portrait and landscape device orientations.

If the problem continues after applying the correct aspect ratio, inspect your website for conflicting media queries, theme styles, or third-party video plugins that might override the embed settings.

Conclusion

Black bars and cropped YouTube Shorts are often the result of incompatible aspect ratios, fixed iframe dimensions, or restrictive website containers.

For individual Shorts, a responsive portrait iframe can resolve many of these issues without requiring a complete website redesign.

However, if your website regularly features multiple Shorts, a responsive YouTube widget like Taggbox can simplify video management and help maintain a more consistent mobile browsing experience.

Frequently Asked Questions

1. Can I remove black bars from YouTube Shorts without cropping the video?

Yes, if the black bars result from an incompatible embed container. Matching the container to the original video's aspect ratio can reduce unnecessary padding without cutting off the footage. Black bars encoded into the original video require video editing.

2. Why does my YouTube Shorts embed revert to 16:9 after publishing?

Your website theme, page builder, or video plugin may apply default responsive styles after the page loads. Inspect the published page and override the conflicting aspect ratio settings specifically for your Shorts container.

3. Can I use different YouTube Shorts aspect ratios on desktop and mobile?

Yes. CSS media queries allow you to assign different container dimensions across screen sizes. However, using a container ratio that differs from the original video may introduce additional empty space or padding.

4. Why are my YouTube Shorts thumbnails cropped even when the videos play correctly?

Thumbnail images and video players are often styled separately. A gallery may crop thumbnails to maintain uniform card sizes while preserving the original video's proportions during playback. Check your gallery's thumbnail sizing and image display settings.

5. Can I display portrait YouTube Shorts and landscape videos in the same feed?

Yes. Use separate aspect ratio settings for individual video containers or a video gallery layout that accommodates mixed video formats. Taggbox supports collecting both regular YouTube videos and Shorts within its YouTube widget.

6. Does fixing the YouTube Shorts aspect ratio improve website performance?

Correct aspect ratio settings help reserve the required space before a video loads, potentially reducing unexpected layout shifts. However, they do not directly reduce the resources required by the YouTube player. Lazy loading below-the-fold embeds can help reduce unnecessary initial loading.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.