12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Jun 20, 2018

How to make YouTube videos take up full width in WordPress

Sridhar Katakam

Updated on November 04, 2019

If you are using the built-in oEmbed feature of WordPress whereby pasting the URL of a YouTube video inserts the video in your post content, adding the following CSS will make the videos take up the full available width of your content with the videos proportionately sized i.e., behave responsively:

/* Make YouTube videos inserted via WordPress oEmbed full-width */

.wp-block-embed-youtube {
	overflow: hidden;
	position: relative;
	max-width: 100%;
	height: auto;
	padding-bottom: 56.25%;
}

.wp-block-embed-youtube iframe,
.wp-block-embed-youtube object,
.wp-block-embed-youtube embed {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}

An example can be seen here.

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-downarrow-right