Blog Banner |
Introduction:
IMAGES ON A WEB PAGE:
- src: is used to indicate the image's path.
- alt: is used to specify an image's alternate text. It is useful since it tells the viewer about the picture's meaning and also because if the image cannot be displayed due to a network issue, this alternate text will be displayed.
- height: is used to determine the image's height.
- width: is used to specify the image's width.
- usemap: is used to specify an image as a client-side image map.
- ismap: is used to specify an image as a server-side image map.
- align: is used to specify the image alignment with value top, bottom, middle, left and right.
- border: is used to specify the width of image border.
Example of image in html:
<!DOCTYPE html> <html> <head> <title>Image Example</title> </head> <body> <h1>Image Example</h1> <img src="example.jpg" alt="Example Image"> </body> </html>
IMAGE FORMATS:
- BMP : Microsoft Windows produced the bitmap (.bmp) format, which is widely used on the internet because to Internet Explorer's popularity. Supports 16.7 million colors and is primarily uncompressed, making it somewhat big.
- JPEG : JPEG (Joint Photographers Expert Group) is a compression standard (not an image format) with the extension.jpg or .jpeg , .jpg. .jpg offers 16.7 million colors with a tiny file size, and is frequently used for high-color photography. However, when compressed, certain details are lost (lossy compression).
- GIF: GIF ( Graphic Interchange Format ) is a popular image format that loses no information when compressed (i.e. lossless compression). The disadvantage of.gif is that it only supports an 8-bit color palette, which means that each picture may only have 256 color's, making it unsuitable for images with numerous colors. Most importantly,.gif allows for animation; a single.gif file may contain several frames, which can then be played in order to produce an animation effect.
- PNG: PNG (Portable Network Graphics) is an open-source image format that may be used for any sort of image on the Internet. File sizes are greater than.jpg (since compression is lossless). PNG allows for 16.7 million color combinations and 256 transparent color's. Suitable for images that just require a few color's. Low color depth data may be compressed into very tiny files.
IMAGE MAPS:
Example of image map in html:
<!DOCTYPE html> <html> <head> <title>Image Map Example</title> </head> <body> <h1>Image Map Example</h1> <img src="worldmap.jpg" alt="World Map" usemap="#map"> <map name="map"> <area shape="rect" coords="0,0,100,100" href="north-america.html" alt="North America"> <area shape="circle" coords="200,200,50" href="europe.html" alt="Europe"> <area shape="poly" coords="300,300,400,400,350,450" href="asia.html" alt="Asia"> </map> </body> </html>
COLORS:
Colors play a significant role in giving your website a pleasing appearance. The <body> tag can be used to set color's for the entire page, or the bgcolor attribute can be used to set color's for individual tags.- bgcolor: specifies the color of the page's background.
- text: specifies the color of the body text is chosen by text.
- alink: specifies changes color of active or selected links.
- link: specifies the color of linked text is determined by the link command.
- vlink: assigns a color to visited links, or linked text that has already been clicked.
Methods of HTML Color Coding:
Example of color's in html:
<!DOCTYPE html> <html> <head> <title>Named Colors Example</title> <style> .red-text { color: red; } .blue-background { background-color: blue; color: white; } </style> </head> <body> <h1 class="red-text">This text is red.</h1> <p class="blue-background">This paragraph has a blue background.</p> </body> </html>
<!DOCTYPE html> <html> <head> <title>Hexadecimal Colors Example</title> <style> .green-text { color: #00FF00; } .purple-background { background-color: #800080; color: white; } </style> </head> <body> <h1 class="green-text">This text is green.</h1> <p class="purple-background">This paragraph has a purple background.</p> </body> </html>
<!DOCTYPE html> <html> <head> <title>RGB Colors Example</title> <style> .blue-text { color: rgb(0, 0, 255); } .yellow-background { background-color: rgb(255, 255, 0); color: black; } </style> </head> <body> <h1 class="blue-text">This text is blue.</h1> <p class="yellow-background">This paragraph has a yellow background.</p> </body> </html>
FORMs in HTML:
- action: When a form is submitted, the action specifies where the form data should be sent.
- name: Specifies the name of the form.
- method: Specifies the HTTP method to use when delivering form-data. Get or Post is the option.
- target: Indicates where the response received after submitting the form should be displayed.
Syntax for creating form:
<!DOCTYPE html> <html> <head> <title>Form Example</title> </head> <body> <h1>Form Example</h1> <form action="submit-form.html" method="POST"> <!-- Input fields and other form elements go here --> <label for="name">Name:</label> <input type="text" id="name" name="name" required> <label for="email">Email:</label> <input type="email" id="email" name="email" required> <input type="submit" value="Submit"> </form> </body> </html>
The <form> element is used to create the form. It has two important attributes:
method: Specifies the HTTP method to be used when submitting the form, typically GET or POST.
Inside the <form> element, you can include various form elements, such as <input>, <textarea>, <select>, etc., to collect user input.
Each input element requires a corresponding <label> element to provide a textual description for the input. The for attribute of the <label> should match the id attribute of the corresponding input element.
In the example, we have included two input fields: one for the name (<input type="text">) and another for the email address (<input type="email">). The name attribute provides a name for each input field, which is used to identify the field when the form is submitted.
The final <input> element with type="submit" creates a submit button. When clicked, it triggers the form submission.
Ensure that you adjust the action attribute to the appropriate URL or path where you want to submit the form data. Additionally, customize the input fields and add additional form elements as needed for your specific form requirements.
INTERACTIVE ELEMENTS:
1. <input> :
- <input type="text"> : It specifies a single-line text input field
- <input type="radio"> : It specifies a radio button. A user can select ONE of a limited number of options using radio buttons.
- <input type="checkbox"> : It specifies a checkbox (for selecting zero or more of many choices)
- <input type="submit"> : It specifies a submit button (for submitting the form). A button for submitting form data to a form-handler is defined by the <input type="submit">.
- <input type="button"> : It specifies a clickable button
- <input type="password"> : It specifies a single-line text password field
- <input type="reset"> : It specifies a reset button that will reset all form values to their default values.
Example of form elements in html:
<!DOCTYPE html> <html> <head> <title>Form Elements Example</title> </head> <body> <h1>Form Elements Example</h1> <form action="submit-form.html" method="POST"> <label for="name">Name:</label> <input type="text" id="name" name="name" required><br> <label for="gender">Gender:</label> <input type="radio" id="male" name="gender" value="male"> <label for="male">Male</label> <input type="radio" id="female" name="gender" value="female"> <label for="female">Female</label><br> <label for="hobbies">Hobbies:</label> <input type="checkbox" id="reading" name="hobbies" value="reading"> <label for="reading">Reading</label> <input type="checkbox" id="music" name="hobbies" value="music"> <label for="music">Music</label> <input type="checkbox" id="sports" name="hobbies" value="sports"> <label for="sports">Sports</label><br> <input type="submit" value="Submit"> <input type="button" value="Cancel"> <input type="password" id="password" name="password" placeholder="Enter password" required><br> <input type="reset" value="Reset"> </form> </body> </html>
- `<input type="text">`: Creates a text input field for the user to enter text.
- `<input type="radio">`: Creates radio buttons for selecting a single option. Radio buttons with the same `name` attribute belong to the same group, and only one option can be selected.
- `<input type="checkbox">`: Creates checkboxes for selecting multiple options. Each checkbox can have a unique `name` attribute.
- `<input type="submit">`: Creates a submit button to submit the form.
- `<input type="button">`: Creates a general button that can be customized with JavaScript.
- `<input type="password">`: Creates a password input field where the entered text is masked.
- `<input type="reset">`: Creates a reset button to clear the form input fields.
2. The labels (`<label>`) are associated with each form element using the `for` attribute. This improves accessibility and allows users to click on the label to focus on the corresponding input field.
3. The form is configured with the `action` attribute to specify where the form data should be submitted and the `method` attribute to define the HTTP method (POST in this case).
2. <textarea> :
Example of <textarea> in html:
<!DOCTYPE html> <html> <head> <title>Textarea Example</title> </head> <body> <h1>Textarea Example</h1> <form action="submit-form.html" method="POST"> <label for="message">Message:</label><br> <textarea id="message" name="message" rows="4" cols="50"></textarea><br> <input type="submit" value="Submit"> </form> </body> </html>
1. The `<textarea>` element is used to create a multi-line text input control. It has the opening and closing tags, similar to a `<div>` or `<p>` element.
2. The `id` attribute uniquely identifies the `<textarea>` element, and the `name` attribute specifies the name of the input field when the form is submitted.
3. The `rows` and `cols` attributes define the size of the text area. In the example, `rows="4"` and `cols="50"` specify that the text area should display four lines and have a width of 50 characters.
4. The `<label>` element is used to provide a descriptive label for the text area. The `for` attribute of the `<label>` should match the `id` attribute of the corresponding `<textarea>` element.
5. The form includes a submit button (`<input type="submit">`) to allow users to submit the form.
3. <label> :
Many form elements have a label defined by the <label> tag. When the user focuses on the input element, the screen-reader will read out loud the label, which is beneficial for screen-reader users.Example of <label> in html:
<!DOCTYPE html> <html> <head> <title>Label Example</title> </head> <body> <h1>Label Example</h1> <form action="submit-form.html" method="POST"> <label for="name">Name:</label> <input type="text" id="name" name="name" required><br> <label for="email">Email:</label> <input type="email" id="email" name="email" required><br> <label for="message">Message:</label><br> <textarea id="message" name="message" rows="4" cols="50"></textarea><br> <input type="submit" value="Submit"> </form> </body> </html>
1. The `<label>` element is used to create a label for each form element. It provides a textual description or name for the associated input element.
2. The `for` attribute of the `<label>` element specifies which input element it is associated with. The value of the `for` attribute should match the `id` attribute of the corresponding input element. This association between the label and input element improves accessibility and helps screen-reader users understand the purpose of the form field.
3. Each input element (text input, email input, textarea) has a corresponding `<label>` element. The labels are positioned before or beside the input elements to create a clear relationship between the label and the input.
4. When the user interacts with the form elements, such as focusing on the input field or clicking on the label, the screen-reader will read the label out loud, providing additional context and information to assistive technology users.
4. <select> :
Example of <select> in html:
<!DOCTYPE html> <html> <head> <title>Select Example</title> </head> <body> <h1>Select Example</h1> <form action="submit-form.html" method="POST"> <label for="country">Country:</label> <select id="country" name="country"> <option value="usa">United States</option> <option value="canada">Canada</option> <option value="uk">United Kingdom</option> <option value="australia">Australia</option> </select><br> <input type="submit" value="Submit"> </form> </body> </html>
1. The `<select>` element is used to create a drop-down list. It allows users to choose a single option from the available options.
2. The `id` attribute uniquely identifies the `<select>` element, and the `name` attribute specifies the name of the input field when the form is submitted.
3. Inside the `<select>` element, `<option>` elements are used to define the available options in the drop-down list. Each `<option>` element has a `value` attribute, which represents the value that will be submitted when the form is submitted. The text between the opening and closing `<option>` tags represents the visible label for each option.
4. The `<label>` element is used to provide a descriptive label for the drop-down list. The `for` attribute of the `<label>` should match the `id` attribute of the corresponding `<select>` element.
5. The form includes a submit button (`<input type="submit">`) to allow users to submit the form.
5. <fieldset> and <legend> :
Example of <fieldset> and <legend> in html:
<!DOCTYPE html> <html> <head> <title>Fieldset and Legend Example</title> </head> <body> <h1>Fieldset and Legend Example</h1> <form action="submit-form.html" method="POST"> <fieldset> <legend>Contact Information</legend> <label for="name">Name:</label> <input type="text" id="name" name="name" required><br> <label for="email">Email:</label> <input type="email" id="email" name="email" required><br> </fieldset> <fieldset> <legend>Preferences</legend> <label for="newsletter">Subscribe to Newsletter:</label> <input type="checkbox" id="newsletter" name="newsletter" value="yes"><br> <label for="color">Favorite Color:</label> <input type="text" id="color" name="color"><br> </fieldset> <input type="submit" value="Submit"> </form> </body> </html>
1. The `<fieldset>` element is used to group related form elements together. It creates a visual container to organize form fields.
2. Inside the `<fieldset>` element, the `<legend>` element is used to provide a caption or description for the group of form fields. The text between the `<legend>` opening and closing tags serves as the caption.
3. The form is divided into two `<fieldset>` sections. The first `<fieldset>` groups the contact information form fields, while the second `<fieldset>` groups the preference-related form fields.
4. Each `<fieldset>` contains `<label>` elements and corresponding form input elements (such as `<input>`, `<textarea>`, etc.) that are relevant to that specific group.
5. The `<label>` elements provide descriptive labels for each form field, enhancing accessibility and usability.
6. The form includes a submit button (`<input type="submit">`) to allow users to submit the form.
WORKING WITH MULTIMEDIA:
Almost everything that can be heard or seen may be considered multimedia (like- sound, music, images, records, videos, films, animations, etc.). It is available in a variety of forms. Multimedia components in many forms and types can be found on web sites. Various multimedia tags in HTML allow you to add a variety of multimedia files to your website.<audio>: Use for displaying a audio file on the web page,
<video>: Use for displaying a video file on the web page,
<embed>: Use for embedding multimedia files on the web page,
<object>: Use for embedding multimedia files on the web page.
<iframe>: Use for embedding other web pages.
Media files include multimedia components such as audio and video. Looking at the file extension is the most common approach to figure out what type of file it is. Formats and extensions for multimedia files include: .wav, .mp3, .mp4, .mpg, .wmv, and .avi.
HTML elements for inserting Audio on a web page:
a) .mp3
b) .wav
c) .ogg
HTML5 allows you to use video and audio controls. The multimedia elements are played using Flash, Silverlight, and other comparable technologies.
<audio> Tag Attributes:
controls: It specifies the audio controls (play/pause buttons) which are shown.
autoplay: When enabled, the audio will begin playing as soon as it is ready. When an audio file is finished, loop signals that it will begin playing again.
muted: It's being used to turn off the audio output while it's muted.
preload: This indicates the author view that when the page loads, it should upload an audio file.
src: This specifies the audio file's source URL.
Example of inserting audio:
<!DOCTYPE html> <html> <head> <title>Audio Example</title> </head> <body> <h1>Audio Example</h1> <audio src="audiofile.mp3" controls> Your browser does not support the audio element. </audio> </body> </html>
1. The `<audio>` tag is used to insert an audio file. The `src` attribute specifies the path or URL of the audio file (`audiofile.mp3` in this case).
2. The `controls` attribute adds default audio controls to the player, such as play/pause buttons and volume control.
3. The text "Your browser does not support the audio element." is displayed inside the `<audio>` element. It serves as a fallback message for browsers that do not support the `<audio>` tag or the specified audio format.
Make sure to replace `"audiofile.mp3"` with the actual file path or URL of the audio file you want to include. You can use other supported audio formats such as WAV or OGG as well, by changing the file extension and providing the appropriate file path or URL.
Remember to include multiple `<source>` elements within the `<audio>` tag to provide alternative audio formats for broader browser compatibility, as different browsers support different audio formats.
HTML elements for inserting Video on a web page:
The <video> tag in HTML allows you to embed video in your document. MP4 and OGG are the video formats that HTML supports. The <source> element is used to identify media, as well as the kind of media and other properties. In the video element, several source elements are allowed, and the browser will use the first format it recognizes.
<video> Tag Attributes:
controls:
It describes the video controls, which include the play/pause
buttons.
height:
It's used to change the height of the video player.
width:
The width of the video player is specified with this attribute.
poster:
When the video isn't playing, the poster is used to define the image that appears on the screen.
autoplay:
The video will start playing as soon as it is available, according to autoplay.
loop:
When the video file is ended, the loop specifies that the video file will begin again from the beginning.
muted:
This option is used to silence the visual output.
preload:
The author is instructed to upload a video file when the page loads.
src:
This specifies the URL of the video file's source.
Example of inserting video:
Here's an example of how to
insert a video file using the `<video>` tag in HTML:
<!DOCTYPE html> <html> <head> <title>Video Example</title> </head> <body> <h1>Video Example</h1> <video controls width="640" height="360" poster="video-poster.jpg" autoplay loop muted preload> <source src="videofile.mp4" type="video/mp4"> <source src="videofile.webm" type="video/webm"> Your browser does not support the video element. </video> </body> </html>
1. The `<video>` tag is used to insert a video file. The
`<source>` tags within the `<video>` tag specify the path or URL
of the video files (`videofile.mp4` and `videofile.webm` in this case).
Multiple `<source>` tags are provided to support different video formats
for broader browser compatibility.
2. The `controls` attribute adds
default video controls to the player, such as play/pause buttons, volume
control, and progress bar.
3. The `width` and `height` attributes specify
the dimensions of the video player in pixels (`width="640"` and `height="360"`
in this case).
4. The `poster` attribute specifies an image that will be
displayed as the video thumbnail or poster before the video starts playing
(`poster="video-poster.jpg"` in this case).
5. The `autoplay` attribute
automatically starts playing the video when the page loads.
6. The `loop`
attribute makes the video loop continuously.
7. The `muted` attribute
sets the video to be muted by default.
8. The `preload` attribute
indicates whether the video should be preloaded when the page loads.
Remember
to replace `"videofile.mp4"`, `"videofile.webm"`, and `"video-poster.jpg"`
with the actual file paths or URLs of the video files and video poster image
you want to include. Additionally, ensure that you provide multiple
`<source>` elements with different video formats to ensure compatibility
across different browsers.
Conclusion:
We have seen:- Image formats such as BMP, JPEG, GIF, and PNG have different characteristics and are suitable for different types of images.
- The `<img>` tag in HTML is used to display an image on a web page, and it has various attributes such as `src`, `alt`, `height`, `width`, and more.
- Image maps allow you to define clickable areas within an image using the `<map>` and `<area>` tags. Different shapes like rectangles, circles, and polygons can be defined.
- Colors can be set for different elements on a web page using attributes like `bgcolor`, `text`, `alink`, `link`, and `vlink`. Colors can be specified using color names, hexadecimal codes, or RGB values.
- HTML forms are used to collect user input and can include various form elements like text inputs, checkboxes, radio buttons, select boxes, and more. The `<form>` tag has attributes like `action`, `method`, and `name`.
- Interactive elements in HTML include various form controls like text inputs, checkboxes, radio buttons, select boxes, and more. These elements have attributes like `name`, `id`, and `value`.
- The `<label>` tag is used to provide a descriptive label for form elements and improves accessibility.
- Multimedia elements like audio and video can be added to web pages using HTML tags like `<audio>` and `<video>`. Attributes like `src`, `controls`, `autoplay`, `loop`, and more can be used to customize the behavior of multimedia elements.
- Different file formats like MP3, WAV, MP4, and OGG are supported for audio and video files in HTML.
- The `<fieldset>` and `<legend>` tags can be used to group related form elements together and provide a caption for the group.
These examples and explanations should help you understand and implement images, colors, forms, interactive elements, and multimedia in your web development projects effectively.