-1

Creating a web page and i would like to add some YouTube videos in it i inserted the correct tags and then inserted the link to the YouTube video but t dose not work with the video i have selected, does anyone know why this is happening and could anyone help. i tried an example from online with a video already selected but when i try change the video it does not appear.

    body {
    margin: auto;
    background-color:     
    font-family: Arial, Helvetica, sans-serif;
    width: auto
    }
    
    .topnav a { 
    float: left;
    color: #f2f2f2;
    text-align: center;
    text-decoration: none;
    font-size: 23px;
    padding-top: 12px;
    padding-right: 16px;
    padding-bottom: 10px;
    padding-left: 16px;
    }
    
    .topnav a:hover {
    background-color: #ddd;
    color: black;
    }
    
    .topnav a.active {
    color: white;
    }
    
    .topnav {
    overflow: hidden;
    background-color: #333;
    }
    
    html {
    background: url(ring.jpg);
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover; 
    background-attachment: fixed;    
    }
<!DOCTYPE html>
       <html>
        
      <head>
        
      <link rel="stylesheet" type="text/css" href="bestknockouts.css">
        
        
      </head>
        
      <body>
          
            
      <div class="topnav">
      <a class="active" href="website.html"><u>Home</u></a>
      <a href="topfighters.html"><u>Top Fighters</u></a>
      <a href="bestknockouts.html"><u>Best Knockouts</u></a>
      <a href="contactpage.html"><u>Contact Page</u></a>
      <a href="https://twitter.com/ItsssOwen">
      <img src="twitter%20link.png"  width="42" height="32" border="0">
      </a>
    </div>
        
    <iframe width="420" height="315"
    src="https://www.youtube.com/watch?v=bOGaYVijgh0">
    </iframe>
        
    </video>
        
    </body>
        
    </html>
Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74
  • 1
    Possible duplicate of [YouTube URL in Video Tag](https://stackoverflow.com/questions/19836015/youtube-url-in-video-tag) – Durga Mar 15 '18 at 12:05

2 Answers2

0

Your structure for embedding YouTube videos is incorrect. To embed a YouTube video the URL needs to be a specific format https://www.youtube.com/embed/ + VIDEO_ID

<iframe width="420" height="315" src="https://www.youtube.com/embed/bOGaYVijgh0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

RH7
  • 223
  • 1
  • 11
0
<iframe width="560" height="315" src="https://www.youtube.com/embed/bOGaYVijgh0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

You are using an incorrect iframe link. Use the above link for it to work.

Whenever you are using YouTube to embed, click on share and then select embed. Then you will get embed like this:

<iframe width="560" height="315" src="https://www.youtube.com/embed/bOGaYVijgh0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
Rob
  • 14,746
  • 28
  • 47
  • 65
  • 1
    Please use proper spelling when writing on Stack Overflow. SO is not reddit. Use more formal writing. Write out "you" and do not use "u". – Rob Mar 15 '18 at 13:07