css align video center code example

Example 1: center a video horizontally

/*option 1:this makes the video responsive*/
.videoDiv
{
    width: 70%; /*or whatever % you prefer*/
    margin: 0 auto;
    display: block;
}

/* option 2* does not make the video responsive*/

.videoDiv{
  margin:0 auto;
  display: block;
}

Example 2: center a video horizontally

<div class="videoDiv">
  <video width="100%" controls>
    <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
    <source src="https://www.w3schools.com/html/mov_bbb.ogg" type="video/ogg">
  Your browser does not support the video tag.
  </video>
</div>

Tags:

Css Example