在 HTML 網頁上新增 YouTube 影片


可以輕鬆地將影片從 YouTube 新增到您的網頁。您只需要嵌入影片即可。

首先,獲取影片編號 −

步驟 1:轉到影片並右鍵單擊。選擇“關於此影片” −

單擊後,您將看到以下對話方塊,顯示統計資訊 −

上面您可以看到影片編號為 F6m0ghjadlw。現在,我們將使用其編號嵌入同一個影片 −

示例

<!DOCTYPE html>
<html>
<head>
   <title>Learn WordPress</title>
</head>
<body>
   <h1>WordPress Installation</h1>
   <p>Following is the video demonstrating how to install WordPress on localhost using
   XAMPP Server:</p>
   <iframe height="350" width="600"
      src="https://www.youtube.com/embed/F6m0ghjadlw">
   </iframe>
</body>
</html>

輸出

以下是成功在網頁上嵌入 YouTube 影片的輸出顯示 −

您還可以使用 <embed> 標記實現相同功能。以下是 HTML 程式碼 −

示例

<!DOCTYPE html>
<html>
<head>
   <title>Learn WordPress</title>
</head>
<body>
   <h1>WordPress Installation</h1>
   <p>Following is the video demonstrating how to install WordPress on localhost using
   XAMPP Server (video uploaded using embed element):</p>
   <embed height="350" width="600" src="https://www.youtube.com/embed/F6m0ghjadlw">
</body>
</html>

輸出

輸出顯示影片已成功嵌入 −

更新於: 2023 年 11 月 24 日

858 次觀看

開啟你的 職業生涯

完成課程即可獲得認證

開始
廣告