Software Development Exam  >  Software Development Notes  >  HTML5 for Web Development  >  Adding Media to Website in HTM

Adding Media to Website in HTM | HTML5 for Web Development - Software Development PDF Download

Introduction

When creating a website, it's important to engage your visitors with various forms of media such as images, videos, and audio files. In this article, we will explore how to add media to a website using HTML. We will cover the basic HTML tags and attributes required to display media elements on a webpage, and provide examples and code explanations to make it easy for beginners to understand.

Adding Images

Images are a great way to enhance the visual appeal of your website. To add an image, follow these steps:

Code Example:

<img src="https://edurev.gumlet.io/mage.jpg" alt="Description of the image">

Explanation:

  • The '<img>' tag is used to embed an image in HTML.
  • The 'src' attribute specifies the source or location of the image file (e.g., '"image.jpg"').
  • The 'alt' attribute provides alternative text for the image, which is displayed if the image fails to load or for accessibility purposes.

Embedding Videos

Videos can be used to showcase product demos, tutorials, or promotional content on your website. To embed a video, you can use the '<video>' tag as shown below:

<video src="https://edurev.gumlet.io/ideo.mp4" controls></video>

Explanation:

  • The '<video>' tag is used to embed a video in HTML.
  • The 'src' attribute specifies the source or location of the video file (e.g., '"video.mp4"').
  • The 'controls' attribute adds playback controls to the video player, allowing users to play, pause, and adjust the volume.

Adding Audio Files

If you want to include audio files, such as background music or podcast episodes, you can use the '<audio>' tag:
Code Example:

<audio src="https://edurev.gumlet.io/udio.mp3" controls></audio>

Explanation:

  • The '<audio>' tag is used to embed audio content in HTML.
  • The 'src' attribute specifies the source or location of the audio file (e.g., '"audio.mp3"').
  • The 'controls' attribute adds audio controls to the player, allowing users to play, pause, and adjust the volume.

Specifying Width and Height

You can adjust the width and height of media elements to control their display size on the webpage. Here's how:
Code Example:

<img src="https://edurev.gumlet.io/mage.jpg" alt="Description of the image" width="300" height="200">

Explanation:

  • The 'width' and 'height' attributes allow you to set the dimensions of the image.
  • In the example, the image will be displayed with a width of 300 pixels and a height of 200 pixels.

Sample Problems

Problem 1: Create an HTML page with an image that is centered on the page and has a width of 500 pixels.

<!DOCTYPE html>

<html>

<head>

    <title>Centered Image</title>

    <style>

        img {

            display: block;

            margin: 0 auto;

            width: 500px;

        }

    </style>

</head>

<body>

    <img src="https://edurev.gumlet.io/mage.jpg" alt="Centered Image">

</body>

</html>

Problem 2: Embed a YouTube video on your webpage and set its width to 800 pixels.

<!DOCTYPE html>

<html>

<head>

    <title>Embedded Video</title>

</head>

<body>

    <iframe width="800" height="450" src="https://www.youtube.com/embed/VIDEO_ID" frameborder="0" allowfullscreen></iframe>

</body>

</html>

Replace '"VIDEO_ID"' with the actual ID of the YouTube video you want to embed.

Conclusion

By following these examples and explanations, you can easily add images, videos, and audio files to your website using HTML. Experiment with different attributes and CSS styles to customize the media elements according to your design preferences.

The document Adding Media to Website in HTM | HTML5 for Web Development - Software Development is a part of the Software Development Course HTML5 for Web Development.
All you need of Software Development at this link: Software Development
20 videos|15 docs|2 tests

Top Courses for Software Development

20 videos|15 docs|2 tests
Download as PDF
Explore Courses for Software Development exam

Top Courses for Software Development

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

video lectures

,

Free

,

Exam

,

Adding Media to Website in HTM | HTML5 for Web Development - Software Development

,

mock tests for examination

,

Semester Notes

,

Summary

,

Adding Media to Website in HTM | HTML5 for Web Development - Software Development

,

shortcuts and tricks

,

Extra Questions

,

Adding Media to Website in HTM | HTML5 for Web Development - Software Development

,

ppt

,

MCQs

,

practice quizzes

,

study material

,

Viva Questions

,

past year papers

,

Previous Year Questions with Solutions

,

Important questions

,

pdf

,

Sample Paper

,

Objective type Questions

;