How to Center YouTube Video Embed

preview_player
Показать описание
In this tutorial you will learn how to center an embedded YouTube video using HTML.

In this tutorial you are going to learn how to center youtube video embed with HTML which is a simple process that just requires the addition of a small bit of code.

Step # 1 -- Viewing the Current Alignment

First of all you need to open the HTML code that contains the video. In this example we have the embed code for the video in Notepad. When we open this code in a browser we can see that by default the video appears on the left of the screen -- this is what we want to change.

Step # 2 -- Inserting the Extra Code

We need to add two extra pieces of code, one right at the beginning of the body which reads "center" and then one at the end which reads "/center". Save the file and this is essentially how to center youtube video embed, navigate back to the web browser, click refresh and you will see that the video now appears in the center of the page.
Рекомендации по теме
Комментарии
Автор

❗ Subscribe To Our Main YouTube Channel

howtechweb
Автор

Here's a better way if you intend on being HTML5 standards-compliant and don't want your page to render in Quirks mode. Add an external stylesheet for your page and add the following:

iframe{
margin-left: auto;
margin-right: auto;
display: block;
border-radius: 5px;
}

Border-radius just rounds the edges of the iframe element in modern browsers. Note that for most elements the margin-left: auto and margin-right:auto are the big determiners of horizontal centered-ness depending on parent element position and width. The display:block treats the element as a block-level element and allows it to "fill the width" of its parent container while the margin properties center it within that parent container.

LuxSaturni
Автор

Sometimes one of the best tutorials is from the past! Thanks a million.

voltronLion
Автор

Seriously the easiest and best way I have found. Thank you!

brookestraitonphotography
Автор

This worked like a charm. Thank you so much!

ShailajaV
Автор

Awesome. So simple, but I've been trying to figure this out for hours. I guess I didn't think it could be that easy!

weliveforvacations
Автор

Thanks, it helped a lot.
Can't believe I forgot one of the most basic things of HTML, its been too long.

GabrielTobing
Автор

this helped me heaps! i completley forgot the center tags hahaha

thescarybobcat
Автор

Struggled for hours trying to center my video, learns to center it in less than a minute. Thank you lmao

miakennedy
Автор

A simple code but very effective! Thank you

yhct-lehuuminh
Автор

Thank you so much! I have been trying to work this out for so long! This video explains it so simply :)

cooranbongfarmhousesoaps
Автор

I used the <iframe> tag and then, this doesnt work. Do I need to change the code?

PianistifiedForYT
Автор

Thank you!!!! All of the other videos didn't work.

californicationvideogame
Автор

This tutorial was so helpful. Thanks

richardatobosomtwi
Автор

Thankyou for your short and concise video, Just what I needed to know.

BeadingBelles
Автор

Thank you very much i was struggling for this only!

dhwanitgohel
Автор

Excellent video. It was exactly what I needed today. Thank you much.

VideoEasyPeasy
Автор

This was helpful and it worked on our site. Thank you!

whatismyhealth
Автор

Thank you very much, simple, easy and clear.

raquelgamboamogollon
Автор

Many thanks for your video. A great help.

petereggison