22889Views7Replies

Author Options:

How can I center an embedded YouTube video (without using the deprecated <center> tag)? Answered

Tags:htmlcss

Discussions

0
None
kenvonrauch

5 years ago

The following thing worked for me:

I put this code in my style.css file:

.youtube {
margin-right: auto;
margin-left: auto;
display:block;
width:700px;
}


And I added my youtube video to the actual post like this:


http://www.youtube.com/watch?v=cUtw7sjnqFg
0
None
threecheersfornickNachoMahma

Answer 9 years ago

. text-align won't work as it is not text
. <div class="youtube"> <video> </div>
+
.youtube {
margin-right: auto;
margin-left: auto
}

didn't work for unknown reasons

0
None
Padlockthreecheersfornick

Answer 8 years ago

Add this before the first object tag:
<div style="text-align:center">
and this after:
</div>

Text align still centers it, even though it is not text.

0
None
iPodGuy

9 years ago

align=center?