Pankaj Shah web agency director in London with over 20 years of experience in web design and project management

I hope you enjoy reading our blog posts.

If you want DCP to build you an awesome website, click here.

HTML5 & CSS3 – Beginners Tutorial – Part 14 – [ HTML 5 Video and Audio Tutorial ]

This tutorial covers how to integrate audio and video into web pages using HTML5. It explains the process of downloading media files, organising them in folders, and using HTML5 tags to create audio and video players. Additionally, it discusses the benefits of using platforms like YouTube and SoundCloud for media hosting.

In this tutorial, we will explore how to use HTML5 to integrate audio and video clips into your web projects. This is part 14 of the DCP Web Designers HTML5 and CSS beginners tutorial series. We will cover the steps to download sample media files, organise them effectively, and implement HTML5 audio and video players on your web pages.

To begin, we need to obtain a sample video and audio file. Open Google Chrome and search for an MP4 video file. Once you find a suitable file, click on the download link and save it to your desktop. For audio, we will use the YouTube Audio Library. Make sure you are logged into your YouTube account to download audio files. Choose a genre, such as classic, and download a track, renaming it to audio.mp3.

Next, we will create a structured folder system to keep our files organised. Create a new folder named assets on your desktop. Inside this folder, create two subfolders: audio and video. This organisation helps maintain a clean root directory, making it easier to manage files when your website grows.

  1. Move the downloaded audio file into the audio folder.
  2. Move the video file into the video folder.

This structure will help you locate files easily when updating or changing content on your website.

Now, let’s open our HTML file using a code editor like Notepad++. We will add the audio and video players to our webpage. First, we will create an audio player using the HTML5 <audio> tag. Here’s how to do it:

    
     <audio controls>
    <source src="assets/audio/audio.mp3" type="audio/mpeg">
    Your browser does not support the audio element.
</audio>

    
   

This code snippet creates an audio player with controls for play, pause, and volume. The src attribute points to the location of the audio file, and the type attribute specifies the file format.

Next, we will add a video player using the HTML5 <video> tag. Similar to the audio player, we need to specify the source of the video file:

    
     <video width="400" height="240" controls>
    <source src="assets/video/video.mp4" type="video/mp4">
    Your browser does not support the video tag.
</video>

    
   

This code creates a video player with specified dimensions and controls. The src attribute points to the video file, and the type attribute indicates the video format.

After adding the audio and video players to your HTML file, save your changes and refresh your browser. You should see both players displayed on the page. You can play the audio and video clips directly in your browser without needing any third-party plugins.

Before HTML5, integrating audio and video into web pages required complex coding or third-party tools. With HTML5, you can easily embed media using just a few lines of code. This simplicity allows for a more efficient workflow and better user experience.

While you can host audio and video files directly on your server, it is often more beneficial to use platforms like YouTube and SoundCloud.

Here are a few reasons:

  1. Cost-Effective: Hosting media on your server can incur high bandwidth costs, especially if your content becomes popular. Using platforms like YouTube or SoundCloud offloads this cost to the service provider.
  2. Increased Exposure: Uploading your videos to YouTube can significantly increase your visibility. YouTube has a vast audience, and your content can reach more viewers compared to hosting it on your own site.
  3. Ease of Use: Both YouTube and SoundCloud provide easy embedding options, allowing you to integrate their players into your website seamlessly.

In this tutorial, we covered how to integrate audio and video into your web projects using HTML5. We discussed downloading media files, organising them in folders, and implementing HTML5 audio and video players. Additionally, we highlighted the advantages of using platforms like YouTube and SoundCloud for hosting your media.

As we move forward in this tutorial series, we will delve into CSS, which will allow us to style and layout our content more effectively. Stay tuned for the next tutorial, where we will explore the exciting possibilities of CSS in web design.

Author

Picture of Pankaj Shah

Pankaj Shah

Pankaj Shah is the founder of DCP Web Designers, an award-winning London-based web design and digital marketing agency. With over 20 years of experience, he specialises in WordPress web design, WooCommerce, SEO and helping businesses build effective online solutions.
Tell Us Your Thoughts

This website (dcpweb.co.uk) uses cookies to improve your browsing experience and help us understand how our site is used. By continuing to browse this website, you agree to our use of cookies.

To learn more about how we collect, use, and protect your data, please read our Privacy Policy.

Since 2004, we have designed and developed websites for companies across a wide range of industries, from local service businesses to ecommerce brands and professional organisations.

Our focus is on creating websites that not only look professional, but also perform well in search engines, attract the right audience and support long-term business growth.

If you are looking for experienced web designers who understand how to build websites that deliver real results, our team is here to help.

Privacy Policy

Last Updated: 01/07/2024

Different Colour Productions Ltd (“we,” “us,” or “our”) is committed to protecting your privacy. This Privacy Policy outlines our practices concerning the collection, use, and disclosure of personal information when you visit our website or engage with our services. By using our website and services, you consent to the terms outlined in this Privacy Policy.

1. Information We Collect

We collect various types of information to provide and improve our services. The types of information we may collect include:

1.1. Personal Information: This may include your name, email address, phone number, and any other information you provide when you contact us, request information, or subscribe to our newsletter.

1.2. Log Data: When you visit our website, we automatically collect information, such as your IP address, browser type, pages visited, and the time and date of your visit.

1.3. Cookies and Similar Technologies: We use cookies and other tracking technologies to improve your experience on our website. You can adjust your browser settings to reject cookies or be alerted when cookies are being used.

2. How We Use Your Information

We use the collected information for various purposes, including:

2.1. Providing Services: To provide web design and related services you have requested from us.

2.2. Communication: To respond to your inquiries, send updates, and provide customer support.

2.3. Analytics: To analyse and improve our website and services, as well as monitor usage patterns.

3. Information Sharing and Disclosure

We do not sell or rent your personal information to third parties. However, we may share your information with third parties under the following circumstances:

3.1. Service Providers: We may share your information with trusted service providers who help us deliver our services, such as hosting providers, analytics providers, and marketing services.

3.2. Legal Obligations: We may disclose your information when required by law, to comply with legal processes, or to protect our rights, privacy, safety, or property.

4. Your Choices

You have choices regarding your personal information:

4.1. Access and Update: You can access and update your personal information by contacting us.

4.2. Marketing Communications: You can opt out of receiving marketing communications from us by following the unsubscribe instructions in our emails or emailing [email protected]

5. Security

We take appropriate measures to protect your personal information from unauthorised access, disclosure, alteration, or destruction.

6. Links to Other Websites

Our website may contain links to third-party websites. We are not responsible for the privacy practices of these websites. We recommend reviewing their respective privacy policies.

7. Changes to this Privacy Policy

We may update this Privacy Policy from time to time to reflect changes in our practices. Any changes will be posted on this page, and the date at the top will indicate the latest update.

8. Contact Us

If you have any questions or concerns about this Privacy Policy or our practices, please contact us at: [email protected]

By using our website and services, you acknowledge that you have read and agree to this Privacy Policy. Different Colour Productions Ltd is committed to safeguarding your personal information and respecting your privacy rights.

ThreeBestRated Top 3 Website Designers in London 2026 award for DCP Web Designers Certificate