Working Code for Embedding Images, Videos, and Audio
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Media Embedding Example</title>
<style>
img, video, audio {
max-width: 100%;
height: auto;
}
</style>
</head>
<body>
<h1>Embedding Media in HTML</h1>
<h2>Embedded Image</h2>
<img src="path/to/image.jpg" alt="Description of the image">
<h2>Embedded Video</h2>
<video controls>
<source src="path/to/movie.mp4" type="video/mp4">
<source src="path/to/movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
<h2>Embedded Audio</h2>
<audio controls>
<source src="path/to/audio.mp3" type="audio/mpeg">
<source src="path/to/audio.ogg" type="audio/ogg">
Your browser does not support the audio element.
</audio>
</body>
</html>
Explanation of Code
HTML Structure: The code begins with a <html> element that declares English as the language and the typical <!DOCTYPE html> declaration. It has a title, viewport settings for responsiveness, a <style> element for CSS rules, and a <head> section with character encoding.
CSS Rules: Within the <style> tag, CSS makes sure that photos, videos, and music all scale proportionately with the width of the device, keeping their aspect ratios within reason and never going wider than the screen.
Media Elements:
This code offers a thorough illustration of how to incorporate and handle media into a webpage, guaranteeing that it is adaptable and viewable on various platforms and web browsers.
Working Code for Embedding Images, Videos, and Audio
|
Explanation of Code
HTML Structure: The code begins with a <html> element that declares English as the language and the typical <!DOCTYPE html> declaration. It has a title, viewport settings for responsiveness, a <style> element for CSS rules, and a <head> section with character encoding.
CSS Rules: Within the <style> tag, CSS makes sure that photos, videos, and music all scale proportionately with the width of the device, keeping their aspect ratios within reason and never going wider than the screen.
Media Elements:
This code offers a thorough illustration of how to incorporate and handle media into a webpage, guaranteeing that it is adaptable and viewable on various platforms and web browsers.
Use the <link> tag inside the <head> to attach an external CSS file.
Comments in HTML are written between <!-- and -->.
HTML entities are used to display reserved or special characters.
The <iframe> tag embeds another webpage within the current page.
The id attribute uniquely identifies a single HTML element.
Hyperlinks are created using the <a> tag with an href attribute.
Use the <img> tag and specify the image source with the src attribute.
Use the target="_blank" attribute inside the <a> tag.
Copyrights © 2024 letsupdateskills All rights reserved