2-Images, Multimedia, and Forms
2-Images, Multimedia, and Forms
This approach ensures that the image is never wider than its
container, thus maintaining its aspect ratio across devices.
2. Audio and Video: Embedding Multimedia Elements
Multimedia elements like audio and video are essential for
interactive websites. HTML5 introduces the <audio> and
<video> tags, which make embedding these media types
easier and more efficient.
Embedding Audio with <audio>
The <audio> tag is used to embed audio files into a webpage.
The syntax is simple:
Form Validation
HTML5 introduced built-in form validation to ensure that users
fill out the form correctly. You can specify required fields and
use attributes like pattern, min, and max for validation.
Example of required field validation:
In this example, the email field is required. If the user tries to
submit the form without filling it in, the browser will prompt
them to enter a value.
Other attributes like pattern, minlength, and maxlength can
help further refine the validation process.
GET vs POST
• GET: Sends data as part of the URL. It is ideal for non-
sensitive data, such as search queries, where security is
not a concern. However, it is limited in the amount of
data it can send (due to URL length restrictions).
• POST: Sends data in the body of the HTTP request,
making it more secure and capable of handling large
amounts of data (such as file uploads).
Creating Buttons
The <button> tag allows developers to create clickable
buttons. Here is how to create different button types:
• Submit Button: Submits the form data.
Conclusion
In this unit, we have explored how to use HTML to work with
images, multimedia elements, and forms. Understanding how
to properly handle these elements will allow you to create
dynamic, interactive, and user-friendly web pages. Whether
you’re displaying images, embedding audio or video, or
collecting data from users through forms, HTML provides the
tools necessary to build modern, responsive websites.