How do you center a video using CSS

center, css, video

Solution

Here's an example: http://jsfiddle.net/Cn7SU/

Just add these CSS rules to the element `video`:

display: block;
margin: 0 auto;

Add the `display: block` property is very important. Otherwise you can't center the element.

Problem

I'm trying to center a video within my site but I don't want to use the center tags in HTML because it's kinda obsolete. How do I do this with CSS? Here's my HTML code if it's any help. ``` <center> <video width="320" height="240" controls> <source src="video.mp4" type="video/mp4"> <source src="video.ogg" type="video/ogg"> <source src="video.webm" type="video/webm"> Your browser does not support the video tag. </video> </center> ```

Original source