Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

how do you center a video in a html document using CSS

how do you center a video in a html document using CSS here is the link https://w.trhou.se/yv870ss83a

Moderator edited: Changed topic of post to reflect question topic of CSS

I think the issue you're having is that you've applied the centering rules to the list element instead of the iframe. It's currently centering the dot that begins the li -- if you want to center the video player, remove the ul li that's containing it, and add this to your CSS:

iframe {display: block; margin: 0 auto;}

link: http://port-80-x0jxhlftzw.treehouse-app.com/

1 Answer

This is the way I would do it.

   <section>
     <div class="videoFrame">
       <iframe width="560" height="315" src="https://www.youtube.com/embed/MyqtIdSSlS0" frameborder="0" allowfullscreen></iframe>
     </div> 
   </section>

With these styles

.videoFrame{
  width:100%:
}

.videoFrame iframe{
   margin: 0 auto;
   display: block;
   width: 560px;
}

I tried adding this, but was getting weird results with Markdown. Guess I need to practice it.