How To Put A Youtube Video On A Website Using Html
Video embedding has become a popular aspect of spider web development. With contempo advancements in the tech industry, developers can embed videos into diverse spider web pages. HTML and CSS have emerged equally some of the popular tools for embedding videos. These languages get paw in hand as a package (alongside JavaScript) to support diverse aspects of web development.
This article provides a guide on how to embed a video into a webpage using HTML and CSS. Information technology also highlights the benefits of video embedding and provides useful tips relating to this miracle.
Table of contents
- What is embedding?
- Overview of HTML and CSS
- Why apply HTML and non HTML5?
- Benefits of embedding a video into your webpage
- Embedding a video into a webpage using HTML and CSS
- Of import Tips
- Determination
What is embedding?
Embedding has various terminologies depending on the context existence used. Embedding ways to attach or insert an object. In the fields of computing and software, embedding refers to attaching a computer hardware component into a figurer software component to execute a highly tailored task.
Embedding can besides exist referred to as incorporating videos, images, GIFs, links or other social media contents into web pages or other social media posts. Embedding allows you to lend a video from a different platform into some other without worrying about compatibility problems like dissimilar software versions or formats.
Video embedding is an activeness of coding that allows you lot to borrow and display a video on your website without pulling it from its original source.
Overview of HTML and CSS
HTML is an abridgement for Hypertext Markup Language. Information technology is a language used for structuring a web folio. It supports various aspects of a web page structure such as the header and body.
CSS is an abbreviation for Cascading Styling Sheets. It is used for styling a HTML web page. CSS makes a web page look presentable through diverse functionalities such as colors, fonts and spacing.
Both HTML and CSS piece of work manus in paw when creating a web page. One does not need to acquire a lot of skills to know the mode around them. Technically, they are both not regarded as programming languages like JavaScript, Python, and the rest, but are found in the forepart-end coding.
Why use HTML and not HTML5?
HTML is an older version of HTML5. It can support near all browsers and is easier to embed a YouTube using the iframe tag.
HTML5 uses the <video>
tag and does non back up all the browsers. This tin can cause a major hassle when adding multiple sources to back up unlike formats.
Iframe is an inline frame that allows items in 1 webpage to be embedded into another webpage. For example, iframe allows yous to embed a YouTube video into another website with ease. By using iframe, you do not take to worry most the file format compatibility issues.
Benefits of embedding a video into your webpage
- It improves the load fourth dimension on your website.
- It allows yous to cull various services for video hosting.
- It increases date with social media posts.
- Users can play the video without having to exit their websites.
Embedding a video into a webpage using HTML and CSS
Prerequisites
You lot volition need the following prerequisites to embed a video:
- A computer
- Stable cyberspace
- A Google account (To admission YouTube)
- A Notebook that supports HTML (The 1 used here is called Sublime Text)
- Coding skills (Basic knowledge virtually HTML and CSS)
- A browser
Side notes on embedding using iframe and URL
- When embedding videos from a website, you can either use the video URL, iframe, or embed the code. In this tutorial, we are going to use the iframe and URL.
- We are going to use YouTube, the famous video platform. Video embedding is not simply limited to videos on YouTube. Yous tin utilise them on whatever social media platform that supports videos like Animoto, Facebook, Flickr, TED, Vimeo, and Vine.
- Choose the video that y'all would similar to embed. Re-create and paste its URL.
- URL stands for Uniform Resource Locator. It specifies the exact location of a content on a computer network.
Steps to Embed a YouTube video into your website
-
Step 1: Open the YouTube page and search for the video that yous would want to embed.
-
Footstep 2: Click on the video to play it.
-
Step iii: Click on the share button.
While the video plays, you volition see a 'share' button below the video. When you lot click on it, you volition find a few sharing options, including diverse social media platforms.
- Step 4: Click on "Embed" as shown in the prototype beneath.
After clicking on 'Embed', YouTube will automatically generate a code for you to use. The iframe tag will accept diverse attributes such equally the URL of the video source, width, and height of the video.
- Step 5: Click on 're-create'.
Click on 'copy' as shown in the prototype below. The copied code will exist pasted in your HTML page.
- Stride half dozen: Open your HTML page.
Locate your HTML page, where you lot want to paste the iframe tag.
- Pace 7: Blazon or paste the iframe tag y'all copied from YouTube into your HTML page.
The code block below shows how you can embed a video in HTML.
<!DOCTYPE html> <html> <head> <title>Put your preferred title</title> <style> trunk{ background-color: purple; background-text: white;} </style> </head> <trunk> <h1>EMBEDDING A VIDEO</h1> <iframe width = "560" height = "315" src = "https://www.youtube.com/embed/t4vKPhjcMZg" title = "YouTube video player" frameborder = "0" allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-moving picture" allowfullscreen></iframe> </body> </html>
You can change the header or background color to accommodate your needs. Click here to test this code.
- Step 8: Save the changes you made on your HTML page.
After saving, while y'all are still on your HTML folio, right click and select "Open in Browser". Your HMTL lawmaking volition run in your browser.
- Stride 9: Your Browser's output.
Depending on your HTML code (or how you have styled it), you can identify the iframe tag anywhere you lot want within your HTML page. After you have successfully embedded a video in your webpage, you lot tin actively collaborate with it.
This means you lot can frontwards, rewind, play, pause, and adjust the book of the video. You can likewise click on the YouTube icon in the embedded page to play the video direct on YouTube. All these activities are called video controls.
- Pace x: Enjoy your view.
As mentioned before, CSS is used for styling your webpage. The in a higher place screenshot contains a dark-brown red background while the screenshot beneath contains a purple groundwork. You tin can play with the HTML and CSS skills to suit your preferences.
Important tips
- Avoid hyperlinked video: The video's URL should be on its own, without whatsoever characters or spaces otherwise information technology will non embed.
- A hyperlink is a highlight done to a link such that when it is clicked or hovered, the browser automatically displays another page or changes the electric current page to show the referenced content.
- You tin can likewise embed images and other contents into a mail service or page equally long as the particular you desire to embed has its own URL.
- If the video you desire to embed is not your ain creation, it is prudent to inquire permission from the owner to avoid copyright infringement.
Conclusion
Forth with knowing how to embed a video using HTML and CSS, we take learned the reasons behind using iframe tag and URL rather than the <video>
tag in HTML5.
To summarize:
- Nosotros have gained an agreement of video embedding.
- We have gained an overview of HTML, CSS, and iframe.
- We accept learned the prerequisites needed before embedding a video.
- We have learned how to embed videos.
- We have known things we should avoid when embedding videos.
Happy coding!
Peer Review Contributions by: Onesmus Mbaabu
Source: https://www.section.io/engineering-education/embedding-a-video-into-a-webpage-using-html-and-css/
Posted by: jaroszgerentow90.blogspot.com
0 Response to "How To Put A Youtube Video On A Website Using Html"
Post a Comment