Forum digitalis

1.6 Media

Media

HTML allows embedding various types of media. Images are added with the <img> tag, audio with <audio>, and videos with <video>. For accessibility and SEO, it's important to provide a descriptive alt text for each media item.

Images

Use <img> to embed images. Attributes like src specify the file path, while alt provides a description for screen readers or when the image cannot be displayed.

Audio & Video

<audio> and <video> allow embedding multimedia files directly on the page. Attributes such as controls display playback controls.

Example

The following example demonstrates embedding an image, audio, and video.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Media Example</title> </head> <body> <h2>Image</h2> <img src="image.jpg" alt="Description of the image"> <h2>Audio</h2> <audio controls> <source src="audio.mp3" type="audio/mpeg"> Your browser does not support audio. </audio> <h2>Video</h2> <video width="320" height="240" controls> <source src="video.mp4" type="video/mp4"> Your browser does not support video. </video> </body> </html>