WP - Unit 1
WP - Unit 1
                                                   1
F.Y.C.S-SEM II                          WEB PROGRAMMING - I                             NOTES – UNIT 1
Every Webpage must contain this code. Explanation of each of the tags used in the below piece of
HTML code:
<!DOCTYPE html>
<!-- Defines types of documents : Html 5.O -->
<html lang="en">
       <!-- DEfines languages of content : English -->
       <head>
       <!-- Information about website and creator -->
       <meta charset="UTF-8">
       <meta http-equiv="X-UA-Compatible" content="IE=edge">
       <!-- Defines the compatibility of version with browser -->
       <meta name="viewport" content="width=device-width, initial-scale=1.0">
       <!-- for make website responsive -->
       <meta name="author" content="Mr.X">
       <meta name="Linkedin profile" content="WWW.linkedin.com/Mr.X_123" >
       <!-- To give information about author or owner -->
       <meta name="description "
       content="A better place to learn computer science">
       <!-- to explain about website in few words -->
       <title>The Title Page</title>
       <!-- Name of website or content to display -->
</head>
<body>
       <!-- Main content of website -->
       <h1>Web Programming - I</h1>
<p>A computer science Course for FY</p>
</body>
</html>
<!DOCTYPE html>: This tag is used to tells the HTML version. This currently tells that the version is
HTML 5.0
<html> </html> : <html> is a root element of html. It’s a biggest and main element in
complete html language, all the tags , elements and attributes enclosed in it or we can say wrap
init , which is used to structure a web page. <html> tag is parent tag of <head> and <body> tag
, other tags enclosed within <head > and <body>. In <html > tag we use “lang” attributes to
define languages of html page such as <html lang=”en”> here en represents English language.
some of them are : es = Spanish , zh-Hans = Chinese, fr= french and el= Greek etc.
<head>: Head tag contains metadata, title, page CSS etc. Data stored in the <head> tag is not
displayed to the user; it is just written for reference purposes and as a watermark of the owner.
          <title> = to store website name or content to be displayed.
          <link> = To add/ link css(cascading style sheet) file.
          <meta> = 1. to store data about website, organisation, creator/ owner
             2. for responsive website via attributes
             3. to tell compatibility of html with browser
          <script> = to add javascript file.
                                                  2
F.Y.C.S-SEM II                          WEB PROGRAMMING - I                            NOTES – UNIT 1
<body>: A body tag is used to enclose all the data which a web page has from texts to links. All
the content that you see rendered in the browser is contained within this element. Following tags
and elements used in the body.
  1 . <h1> ,<h2> ,<h3> to <h6>
  2. <p>
  3. <div> and <span>
  4. <b>, <i> and<u>
  5. <li>,<ul>and<ol>.
  6. <img> , <audio> , <video> and<iframe>
  7. <table> <th> , <thead>and<tr>.
  8. <form>
  9. <label> and
10. <input>          etc……….
➢ Elements & Attributes :
Tags are individuals of html structure; we must open and close any tag with a forward slash like this
<h1> </h1>. There are some variations with the tag some of them are self-closing tag which isn’t
required to close and some are empty tag where we can add any attributes in it. Attributes are
additional properties of html tags that define the property of any html tags. i.e. width, height,
controls, loops, input, and autoplay. These attributes also help us to store information in meta tags
by using name, content, and type attributes.
HTML Tags: Tags are the starting and ending parts of an HTML element. They begin with < symbol
and end with > symbol. Whatever written inside < and > are called tags.
HTML elements: Elements enclose the contents in between the tags. They consist of some kind of
structure or expression. It generally consists of a start tag, content and an end tag.
HTML Attributes: It is used to define the character of an HTML element. It always placed in the
opening tag of an element. It generally provides additional styling (attribute) to the element.
Some Void elements are <br> (represents a line break) , <hr>(represents a horizontal line), etc.
Nested HTML Elements: HTML can be nested, which means an element can contain another element.
Block-level element:
    o   These are the elements, which structure main part of web page, by dividing a page into coherent
        blocks.
    o   A block-level element always start with new line and takes the full width of web page, from left
        to right.
    o   These elements can contain block-level as well as inline elements.
<address>, <article>, <aside>, <blockquote>, <canvas>, <dd>, <div>, <dl>, <dt>, <fieldset>,
<figcaption>, <figure>, <footer>, <form>, <h1>-<h6>, <header>, <hr>, <li>, <main>, <nav>,
<noscript>, <ol>, <output>, <p>, <pre>, <section>, <table>, <tfoot>, <ul> and <video>.
Inline elements:
    o   Inline elements are those elements, which differentiate the part of a given text and provide it a
        particular function.
    o   These elements does not start with new line and take width as per requirement.
    o   The Inline elements are mostly used with other elements.
<a>, <abbr>, <acronym>, <b>, <bdo>, <big>, <br>, <button>, <cite>, <code>, <dfn>, <em>, <i>,
<img>, <input>, <kbd>, <label>, <map>, <object>, <q>, <samp>, <script>, <select>, <small>,
<span>, <strong>, <sub>, <sup>, <textarea>, <time>, <tt>, <var>.
The HTML <b> element defines bold text, without any extra importance.
The HTML <strong> element defines text with strong importance. The content inside is typically displayed in
bold.
Result:
Result:
                                                       6
F.Y.C.S-SEM II                            WEB PROGRAMMING - I                              NOTES – UNIT 1
»DIV and SPAN elements
Both the tags (<div> and <span>) are used to represent the part of the webpage, <div> tag is used
a as block part of the webpage and <span> tag is used as a inline part of the webpage.
HTML <div> tag: The div tag is known as Division tag. The div tag is used in HTML to make divisions
of content on the web page like (text, images, header, footer, navigation bar, etc). Div tag has both
opening(<div>) and closing (</div>) tags and it is mandatory to close the tag. As we know Div tag
is a block-level tag. In this example, the div tag contains the entire width. It will be displayed div tag
each time on a new line, not on the same line.
<div> div tag </div>
 <div> div tag </div>
Result:
HTML <span> tag: The HTML span element is a generic inline container for inline elements and
content. It used to group elements for styling purposes (by using the class or id attributes). A better
way to use it when no other semantic element is available. The span tag is very similar to the div tag,
but     div      is    a     block-level      tag    and      span      is     an       inline    tag.
Result:
                                                    7
F.Y.C.S-SEM II                             WEB PROGRAMMING - I                                 NOTES – UNIT 1
Example
<a href="https://www.ModelCollege.com/">Visit ModelCollege.com!</a>
By default, links will appear as follows in all browsers:
   • An unvisited link is underlined and blue
   • A visited link is underlined and purple
   • An active link is underlined and red
Example
Use target="_blank" to open the linked document in a new browser window or tab:
                                                      8
F.Y.C.S-SEM II                               WEB PROGRAMMING - I                               NOTES – UNIT 1
<a href="https://www.ModelCollege.com/" target="_blank">Visit ModelCollege!</a>
If target="_blank", the link will open in a new browser window or tab.
Example:
<h2>Absolute URLs</h2>
<p><a href="https://www.w3.org/">W3C</a></p>
<p><a href="https://www.google.com/">Google</a></p>
<h2>Relative URLs</h2>
<p><a href="html_images.asp">HTML Images</a></p>
<p><a href="/css/default.asp">CSS Tutorial</a></p>
Output:
Example
<a href="default.asp">
<img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;">
</a>
                                                      9
F.Y.C.S-SEM II                              WEB PROGRAMMING - I                                 NOTES – UNIT 1
Button as a Link
To use an HTML button as a link, you have to add some JavaScript code.
JavaScript allows you to specify what happens at certain events, such as a click of a button:
Example:
<button onclick="document.location='default.asp'">HTML Tutorial</button>
Output
Link Titles
The title attribute specifies extra information about an element. The information is most often shown as a
tooltip text when the mouse moves over the element.
Example:
<a href="https://www.w3schools.com/html/" title="Go to W3Schools HTML section">Visit our HTML
Tutorial</a>
➢ Tables in HTML
The HTML Table is an arrangement of data in rows and columns in tabular format. Tables are useful
for various tasks such as presenting text information and numerical data. A table is a useful tool for
quickly and easily finding connections between different types of data. Tables are also used to create
databases.
<table>          -- Defines the structure for organizing data in rows and columns within a web page.
<th> -- Shows a table header cell that typically holds titles or headings.
<thead> -- Defines the header section of a table, often containing column labels.
<tbody> -- Represents the main content area of a table, separating it from the header or footer.
<tfoot> -- Specifies the footer section of a table, typically holding summaries or totals.
<col> -- Defines attributes for table columns that can be applied to multiple columns at once.
<colgroup> -- Groups together a set of columns in a table to which you can apply formatting or
properties collectively.
                                                      10
F.Y.C.S-SEM II                           WEB PROGRAMMING - I                               NOTES – UNIT 1
In HTML tables, the rowspan and colspan attributes are used to control the layout and structure of
cells, allowing them to span multiple rows or columns. These attributes are particularly useful when
you need to create more complex table structures.
1. rowspan Attribute:
    •   The rowspan attribute is used to make a cell span multiple rows vertically.
    •   It is applied to a <td> (table data) or <th> (table header) element.
    •   The value of rowspan specifies the number of rows the cell should span.
Example:
<table border="1">
   <tr>
      <td rowspan="2">Cell 1</td>
      <td>Cell 2</td>
      <td>Cell 3</td>
   </tr>
   <tr>
      <td>Cell 4</td>
      <td>Cell 5</td>
   </tr>
</table>
2. colspan Attribute:
    •   The colspan attribute is used to make a cell span multiple columns horizontally.
    •   It is applied to a <td> or <th> element.
    •   The value of colspan specifies the number of columns the cell should span.
Example:
<table border="1">
   <tr>
      <td colspan="2">Cell 1</td>
      <td>Cell 2</td>
   </tr>
   <tr>
      <td>Cell 3</td>
      <td>Cell 4</td>
      <td>Cell 5</td>
   </tr>
</table>
Using a combination of rowspan and colspan, you can create more intricate table layouts. These
attributes help improve the visual presentation of data and allow for a more organized and readable
representation of information in HTML tables.
   1. border Attribute:
Specifies the width of the border around the table and its cells.
                                                   11
F.Y.C.S-SEM II                           WEB PROGRAMMING - I                               NOTES – UNIT 1
Example: <table border="1">
   2. width Attribute:
Sets the width of the table. It can be specified in pixels or as a percentage of the available space.
Example: <table width="50%">
   3. cellpadding Attribute:
Specifies the padding between the content of a cell and its borders.
Example: <table cellpadding="5">
   4. cellspacing Attribute:
Specifies the spacing between cells.
Example: <table cellspacing="10">
   5. summary Attribute:
Provides a summary or description of the content and structure of the table.
Example: <table summary="Monthly Sales Data">
   6. align Attribute:
Specifies the horizontal alignment of the table within its containing element (left, center, right).
Example: <table align="center">
   7. bgcolor Attribute:
Sets the background color for the entire table.
Example: <table bgcolor="#FFFFCC">
   8. bordercolor Attribute:
Specifies the color of the table border.
Example: <table bordercolor="#000000">
These attributes can be used individually or in combination to customize the appearance and layout
of HTML tables. It's important to note that some attributes, like border, cellpadding, and cellspacing,
are considered somewhat outdated in modern web development, and styling is often achieved
through CSS for better flexibility and control.
Images are not technically inserted into a web page; images are linked to web pages. The <img> tag
creates a holding space for the referenced image.
Also, always specify the width and height of an image. If width and height are not specified, the page
might flicker while the image loads.
To link an image to another document, simply nest the <img> tag inside an <a> tag.
<img src="smiley.gif" alt="Smiley face" width="42" height="42" style="vertical-align:bottom">
<img src="smiley.gif" alt="Smiley face" width="42" height="42" style="vertical-align:middle">
<img src="smiley.gif" alt="Smiley face" width="42" height="42" style="vertical-align:top">
                                                    12
F.Y.C.S-SEM II                            WEB PROGRAMMING - I                               NOTES – UNIT 1
<img src="smiley.gif" alt="Smiley face" width="42" height="42" style="float:right">
<img src="smiley.gif" alt="Smiley face" width="42" height="42" style="float:left">
Attributes
Attribute            Value                 Description
alt                  text                  Specifies an alternate text for an image
crossorigin          anonymous             Allow images from third-party sites that allow cross-origin
➢ Image Maps
In image mapping an image is specified with certain set of coordinates inside the image which act as
hyperlink areas to different destinations. It is different from an image link since in image linking, an
image can be used to serve a single link or destination whereas in a mapped image, different
coordinates of the image can serve different links or destinations.
Elements required in Mapping an Image :
There are three basic html elements which are required for creating a mapped image.
   1. Map : It is used to create a map of the image with clickable areas.
   2. Image : It is used for the image source on which mapping is done.
   3. Area : It is used within the map for defining clickable areas.
Steps to create a mapped image :
   1. Determining Image size :
Determining the size of the image is very important because if the size of the image is changed then
the area coordinates will also require updation.
                                                   13
F.Y.C.S-SEM II                          WEB PROGRAMMING - I                              NOTES – UNIT 1
For Example:
<img src="workplace.jpg" alt="Workplace" usemap="#workmap" width="400" height="379">
<map name="workmap">
 <area shape="rect" coords="34,44,270,350" alt="Computer" href="computer.htm">
 <area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm">
 <area shape="circle" coords="337,300,44" alt="Cup of coffee" href="coffee.htm">
</map>
➢ Describing Colors
HTML colors are specified with predefined color names, or with RGB, HEX, HSL, RGBA, or HSLA values.
Background Color
You can set the background color for HTML elements:
<h1 style="background-color:DodgerBlue;">Hello World</h1>
<p style="background-color:Tomato;">It’s a Beautiful Day</p>
                                                  14
F.Y.C.S-SEM II                            WEB PROGRAMMING - I                               NOTES – UNIT 1
Text Color
You can set the color of text:
Example
<h1 style="color:Tomato;">Hello World</h1>
<p style="color:DodgerBlue;">It’s a Beautiful Day.</p>
<p style="color:MediumSeaGreen;">Let’s explore the wisdom</p>
Border Color
You can set the color of borders:
<h1 style="border:2px solid Tomato;">Hello World</h1>
<h1 style="border:2px solid DodgerBlue;">Hello World</h1>
<h1 style="border:2px solid Violet;">Hello World</h1>
                                                    15
F.Y.C.S-SEM II                            WEB PROGRAMMING - I                              NOTES – UNIT 1
The HTML <form> element is used to create an HTML form for user input:
<form>
.
form elements
.
</form>
Form Elements:
<label>: It defines label for <form> elements.
<input>: It is used to get input data from the form in various types such as text, password, email, etc
by changing its type.
<button>: It defines a clickable button to control other elements or execute a functionality.
<select>: It is used to create a drop-down list.
<textarea>: It is used to get input long text content.
<fieldset>: It is used to draw a box around other form elements and group the related data.
<legend>: It defines a caption for fieldset elements.
<datalist>: It is used to specify pre-defined list options for input controls.
<output>: It displays the output of performed calculations.
<option>: It is used to define options in a drop-down list.
<optgroup>: It is used to define group-related options in a drop-down list.
The <form> element is a container for different types of input elements, such as: text fields, checkboxes,
radio buttons, submit buttons, etc.
The <input> Element
The HTML <input> element is the most used form element.
An <input> element can be displayed in many ways, depending on the type attribute.
Here are some examples:
Type                                        Description
<input type="text">                  Displays a single-line text input field
<input type="radio">                 Displays a radio button (for selecting one of many choices)
<input type="checkbox">              Displays a checkbox (for selecting zero or more of many choices)
<input type="submit">                Displays a submit button (for submitting the form)
<input type="button">                Displays a clickable button
                                                    17
F.Y.C.S-SEM II                             WEB PROGRAMMING - I                          NOTES – UNIT 1
Radio Button in an HTML Form
To create a radio button, we use the <input> tag following by radio type to provide users to choose a
limited number of choices. The value attribute defines the unique value associated with each radio
button. The value is not shown to the user, but is the value that is sent to the server on “submit” to
identify which radio button that was selected.
Syntax:
<input type="radio" name="radio_button_name" value="radio_button_value" />
The radio button must have shared the same name to be treated as a group.
Here we create a radio button to choose your gender.
<h3>Choose Your Gender</h3>
       <form>
          <label>
                 Male
                 <input type="radio" '
                 name="gender" value="male" />
          </label>
          <label>
                 Female
                 <input type="radio"
                 name="gender" value="female" />
          </label>
       </form>
                                                   18
F.Y.C.S-SEM II                                WEB PROGRAMMING - I                  NOTES – UNIT 1
<h3>Choose Language</h3>
       <form>
          <ul style="list-style-type:none;">
                 <li><input type="checkbox"
                   name="language" value="hindi" />
                   Hindi
                 </li>
                 <li><input type="checkbox"
                   name="language" value="english" />
                   English
                 </li>
                 <li><input type="checkbox"
                   name="language" value="sanskrite" />
                   Sanskrit
                 </li>
          </ul>
       </form>
                                                      19
F.Y.C.S-SEM II                             WEB PROGRAMMING - I                         NOTES – UNIT 1
The “name” and “value” attributes are used to send the Combobox data to the server.
Example: In this example, we will create a dropdown menu to select Nationality.
<h3>Choose Your Nationality</h3>
       <form>
          <select name="language">
                 <option value="indian">
                  Indian
                  </option>
                 <option value="nepali">
                  Nepali
                  </option>
                 <option value="others">
                  Others
                  </option>
          </select>
       </form>
                                                   20
F.Y.C.S-SEM II                            WEB PROGRAMMING - I   NOTES – UNIT 1
                 </label>
           </p>
           <p>
                 <label>
                   Password:
                   <input type="password" />
                 </label>
           </p>
           <p>
                 <button type="submit">Submit</button>
           </p>
       </form>
   </div>
   <script>
       function showAlert(event) {
           // Prevents the default form submission
           event.preventDefault();
           alert('Form submitted!');
       }
   </script>
                                                     21
F.Y.C.S-SEM II                               WEB PROGRAMMING - I                                  NOTES – UNIT 1
TextArea in an HTML Form
In the HTML form, a text area is used to add comments or reviews, or addresses to the form, in other
words, the text area is a multi-line text input control. It contains an unlimited number of characters, the
text renders in a fixed-width font, and the size of the text area is given by the <rows> and <cols>
attributes. To create a text area in the form use the <textarea> tag.
Syntax:
<textarea name="textarea_name">content</textarea>
The name attribute is used to reference the textarea data after it is sent to a server.
Example: In this example, we will create a textarea.
          <form>
           <textarea name="welcomeMessage"
                   rows="23" cols="40">
             This is an online portal
          </textarea>
        </form>
➢ BUTTON
The HTML <button> tag is utilized to create clickable buttons within a webpage. It is commonly employed to
trigger actions or submit form data. The <button> element in HTML allows the inclusion of text and various
tags like <i>, <b>, <a>, <span>,<div>.
This flexibility in content is not achievable within a button created using the <input> element. Various
browsers may have different default behaviors for <button>. Additionally, buttons can be styled using CSS to
change their appearance and design.
Note:
It is important to always specify the type attribute for a button element to inform the browser what type of
button it is.
The HTML <button> tag supports the Global Attribute and Event Attribute in HTML.
Syntax:
<button type = "button"> Click Me </button>
Attributes              Descriptions
Autofocus               It is used to specify that the button should get automatically get focus or not when the
                        page loads
Disabled                It is used indicates whether the element is disabled or not. If this attribute is set, the
                        element is disabled.
                                                        22
F.Y.C.S-SEM II                              WEB PROGRAMMING - I                                 NOTES – UNIT 1
Form                   It is used to create a form for user input. There are many elements that> are used
                       within the >form tag.
Formaction             It is used to specify where to send the data of the form.
Formnovalidate         It is used to specify that the Input Element should not be validated when submitting
                       the form.
Formenctype            It is used to specify that the form data should be encoded when submitting to the
                       server.
Formmethod             It is used to specify the HTTP method used to send data while submitting the form.
Formtarget             It is used to specify the name or a keyword which indicates where to display the
                       response after submitting the form.
Type                   It is used to specify the type of button for button elements. It is also used in <input>
                       element to specify the type of input to display.
Value                  It is used to specify the value of the element with which it is used. It has different
                       meaning for different HTML elements.
Example 1:
<body>
  <h3>HTML button Tag</h3>
   <!-- Button tag starts from here -->
  <button type="button"
        onclick="alert('Welcome to HTML Page')">
     Click Here
  </button>
  <!-- Button tag ends here -->
</body>
Example 2:
<body>
   <button class="blue">Primary</button>
                                                      23
F.Y.C.S-SEM II                           WEB PROGRAMMING - I                               NOTES – UNIT 1
   <button class="green">Secondary</button>
   <button class="warnning">Warning</button>
   <button class="red">Danger</button>
</body>
➢ Multiple-choice
The <select> element is used to create a drop-down or multiple-choice list.
The <select> element is most often used in a form, to collect user input.
The name attribute is needed to reference the form data after the form is submitted (if you omit the
name attribute, no data from the drop-down list will be submitted).
The id attribute is needed to associate the drop-down list with a label.
The <option> tags inside the <select> element define the available options in the drop-down list.
Always add the <label> tag for best accessibility practices!
Attribute            Value                 Description
autofocus            autofocus             Specifies that the drop-down list should automatically get
                                           focus when the page loads
disabled             disabled              Specifies that a drop-down list should be disabled
form                 form_id               Defines which form the drop-down list belongs to
multiple             multiple              Specifies that multiple options can be selected at once
name                 name                  Defines a name for the drop-down list
required             required              Specifies that the user is required to select a value before
                                           submitting the form
size                 number                Defines the number of visible options in a drop-down list
Example 1:
<body>
<h1>The optgroup element</h1>
<p>The optgroup tag is used to group related options in a drop-down list:</p>
<form action="/action_page.php">
 <label for="cars">Choose a car:</label>
                                                   24
F.Y.C.S-SEM II                            WEB PROGRAMMING - I                            NOTES – UNIT 1
 <select name="cars" id="cars">
   <optgroup label="Swedish Cars">
     <option value="volvo">Volvo</option>
     <option value="saab">Saab</option>
   </optgroup>
   <optgroup label="German Cars">
     <option value="mercedes">Mercedes</option>
     <option value="audi">Audi</option>
   </optgroup>
 </select>
 <br><br>
 <input type="submit" value="Submit">
</form>
</body>
➢ TEXTAREA
The <textarea> tag defines a multi-line text input control.
The <textarea> element is often used in a form, to collect user inputs like comments or reviews.
A text area can hold an unlimited number of characters, and the text renders in a fixed-width font
(usually Courier).
The size of a text area is specified by the cols and rows attributes (or with CSS).
The name attribute is needed to reference the form data after the form is submitted (if you omit the
name attribute, no data from the text area will be submitted).
The id attribute is needed to associate the text area with a label.
Always add the <label> tag for best accessibility practices!
Attribute        Value              Description
autofocus        autofocus          Specifies that a text area should automatically get focus when the
                                                    25
F.Y.C.S-SEM II                             WEB PROGRAMMING - I                             NOTES – UNIT 1
                                    page loads
cols             number             Specifies the visible width of a text area
dirname          textareaname.dir   Specifies that the text direction of the textarea will be submitted
disabled         disabled           Specifies that a text area should be disabled
form             form_id            Specifies which form the text area belongs to
maxlength        number             Specifies the maximum number of characters allowed in the text
                                    area
name             text               Specifies a name for a text area
placeholder      text               Specifies a short hint that describes the expected value of a text
                                    area
readonly         readonly           Specifies that a text area should be read-only
required         required           Specifies that a text area is required/must be filled out0
rows             number             Specifies the visible number of lines in a text area
wrap             hard/soft          Specifies how the text in a text area is to be wrapped when
                                    submitted in a form
Example:
<body>
<h1>The textarea element - Disable default resize option</h1>
<p><label for="Feedback Review">Review of Colleges:</label></p>
<textarea id="review" name="review" rows="4" cols="50">
At colleges.com you will learn how to make a website. They offer free lectures in all web development
technologies.
</textarea>
</body>
➢ LABEL
The <label> tag defines a label for several elements:
<input type="checkbox">
<input type="color">
<input type="date">
<input type="datetime-local">
<input type="email">
                                                   26
F.Y.C.S-SEM II                          WEB PROGRAMMING - I                             NOTES – UNIT 1
<input type="file">
<input type="month">
<input type="number">
<input type="password">
<input type="radio">
<input type="range">
<input type="search">
<input type="tel">
<input type="text">
<input type="time">
<input type="url">
<input type="week">
<meter>
<progress>
<select>
<textarea>
Proper use of labels with the elements above will benefit:
Screen reader users (will read out loud the label, when the user is focused on the element)
Users who have difficulty clicking on very small regions (such as checkboxes) - because when a user
clicks the text within the <label> element, it toggles the input (this increases the hit area).
The for attribute of <label> must be equal to the id attribute of the related element to bind them
together. A label can also be bound to an element by placing the element inside the <label> element.
Example:
<body>
<p>A label element is displayed like this:</p>
<input type="radio" id="html" name="fav_language" value="HTML">
<label for="html">HTML</label><br>
<input type="radio" id="css" name="fav_language" value="CSS">
<label for="css">CSS</label><br>
<input type="radio" id="javascript" name="fav_language" value="JavaScript">
<label for="javascript">JavaScript</label>
</body>
                                                  27
F.Y.C.S-SEM II                            WEB PROGRAMMING - I                          NOTES – UNIT 1
                                                  28
F.Y.C.S-SEM II                           WEB PROGRAMMING - I                              NOTES – UNIT 1
➢ Interactive Elements
Inputs
The other most common way you've probably interacted with websites is through inputs. At some point,
you've probably been asked to enter a username and password for a website. Maybe there was a
checkbox that asked if you had read a Terms of Service page, or something along those lines, and
maybe a drop-down menu that asks you to choose an option from many. If you've ever created an
account on this website, for example, you've seen and used all three:
Each of these options is a type of HTML input. For example, these are the elements for a text input (like
the ones you type a username or password into) and a checkbox input:
<input type="text">
<input type="checkbox">
                                                   29
F.Y.C.S-SEM II                            WEB PROGRAMMING - I                             NOTES – UNIT 1
Notice that they actually use the same HTML element, <input>, with different HTML attribute values.
Those values give the browser enough information to display two completely different things when
loaded:
A drop-down input, on the other hand, is made using a select element, which contains a number of
option elements. The HTML would look like something like this:
<select>
 <option>The First Option</option>
 <option>Another One</option>
 <option>Bunch of Options Here</option>
</select>
This element is structured similarly to the <ol> and <ul> elements you used to make lists. That's
because the <select> element itself isn't displayed; instead, it acts as instructions to tell the browser
how to display the <option> elements nested inside. If you were to display the HTML above in the
browser, you'd see this:
    •   WAV: This is an uncompressed audio format developed by Microsoft and IBM. WAV documents
        include raw, lossless PCM (Pulse Code Modulation) audio statistics—high audio incredible but
        huge record sizes.
    •   MP3: MP3 is the most famous compressed audio layout. uses lossy” compression, doing away
        with inaudible sounds to reduce the file duration significantly while maintaining brilliant audio
        Widely supported.
    •   FLAC (Free Lossless Audio Codec) It also losslessly compresses audio records without dropping
        the first-rate; however, the documents are larger than MP3s. Used wherein better pleasantness
        is preferred.
    •   WMA (Windows Media Audio) Compressed audio layout was advanced via Microsoft as an
        alternative to MP3. Contains DRM duplicate protection capabilities.
    •   AAC (Advanced Audio Coding) A standardized and improved version of MP3 Used through
        Apple’s iTunes shop. Can produce more wonderful than MP3 at comparable bit expenses.
                                                    30
F.Y.C.S-SEM II                            WEB PROGRAMMING - I                               NOTES – UNIT 1
    •   AIFF (Audio Interchange File Format) An uncompressed audio layout is superior to the useful
        resources of Apple. Contains first-rate audio.
    •   Ogg Vorbis is a free, open-source compressed audio format. Alternative to MP3 and AAC.
    •   MIDI: Stores virtual sheet music facts in preference to audio waveforms. Used for virtual music
        and computer-generated songs.
    •   Compression: Formats like MP3, AAC, and Ogg Vorbis use compression algorithms to reduce
        the file period of audio records. This saves storage space and transmission bandwidth.
    •   Standardization: Popular formats like WAV, MP3, and FLAC are standardized, permitting
        compatibility between systems and gadgets. They may be completed another time reliably.
    •   Metadata assist: Formats like MP3, WMA, and FLAC can save metadata tags with information
        about the audio document, like call, artist, album, tune, wide variety, and so on.
    •   Streaming manual: compressed codecs allow streaming audio over the internet, permitting
        online track and radio services.
    •   Error correction: Some codecs have mistake correction skills to mitigate information corruption
        issues at some unspecified time in the future of transmission. Makes streaming more robust.
    •   Lossless compression: FLAC and precise lossless codecs compress audio without an awesome
        loss for archival capabilities.
    •   Platform independence: cross-platform formats like WAV, FLAC, and Ogg Vorbis may be used
        throughout precise structures.
    •   Hardware compatibility: most gadgets, like phones, gamers, and lots of others, Aid famous
        codecs for playback on the go with the flow.
    •   Flash Video Format (.flv) This video format is very popular due to the availability of flash player
        for cross platform. These video files are supported by almost every browser making suitable for
        web. This format is compact and support progressive and streaming download. Some users of
        this format are Youtube, Yahoo! Video, VEVO etc.
    •   AVI format (.avi) Audio Video Interleave which can contain both audio and video data. It was
        developed by Microsoft. It uses less compression can contain almost any codecs. It is popular
        among internet user due to multiple codecs support. This means that even if AVI files may look
        similar on the outside are different from one another on the inside All windows OS support this
        format including another player for other platform exist.
    •   MP4 (.mp4) This format is used to store to store audio and video stream online. MP4 file format
        was created by Moving Picture Experts Group (MPEG) as a multimedia container format store
        audiovisual data. It used different compression technique for video and audio.
    •   3GP (.3gp) This is both audio and video file format which was designed to transmit data between
        3G phones and the internet. It is most commonly used to capture video from the phone and
        upload it online. Both Windows and Mac support the format.
    •   WMV (Windows Media Video) This format was developed by Microsoft. It was designed for web
        streaming applications. WMV files are the very small in size over the Web, as their file size
                                                    31
F.Y.C.S-SEM II                               WEB PROGRAMMING - I                               NOTES – UNIT 1
          decreases after compression, due to which results in poor video quality. But this make it only
          file format which can be send through e-mail.
      •   QuickTime Format (.mov) This format was developed by Apple.It can store multiple tracks(for
          different language), text file(subtitle) and effects. MOV files are of high quality and are usually
          big in file size. It is supported both by Windows and Apple.
Video Tag
The <video> tag is used to embed video content in a document, such as a movie clip or other video
streams.
                                                      32
F.Y.C.S-SEM II                               WEB PROGRAMMING - I                              NOTES – UNIT 1
The <video> tag contains one or more <source> tags with different video sources. The browser will
choose the first source it supports.
The text between the <video> and </video> tags will only be displayed in browsers that do not support
the <video> element.
There are three supported video formats in HTML: MP4, WebM, and OGG.
Attribute        Value        Description
autoplay         autoplay     Specifies that the video will start playing as soon as it is ready
controls         controls     Specifies that video controls should be displayed (such as a play/pause
                              button etc).
height           pixels       Sets the height of the video player
loop             loop         Specifies that the video will start over again, every time it is finished
muted            muted        Specifies that the audio output of the video should be muted
poster           URL          Specifies an image to be shown while the video is downloading, or until
                              the user hits the play button
preload          auto         Specifies if and how the author thinks the video should be loaded when
                 metadata     the page loads
                 none
src              URL          Specifies the URL of the video file
width            pixels       Sets the width of the video player
Example:
<video width="320" height="240" controls>
 <source src="movie.mp4" type="video/mp4">
 <source src="movie.ogg" type="video/ogg">
 Your browser does not support the video tag.
</video>
Embed Tag
The <embed> tag defines a container for an external resource, such as a web page, a picture, a media
player, or a plug-in application.
Attribute        Value        Description
height           pixels       Specifies the height of the embedded content
src              URL          Specifies the address of the external file to embed
type             media_type   Specifies the media type of the embedded content
                                                     33
F.Y.C.S-SEM II                       WEB PROGRAMMING - I                 NOTES – UNIT 1
width            pixels   Specifies the width of the embedded content
Example 1:
<embed type="image/jpg" src="pic_trulli.jpg" width="300" height="200">
Example 2:
<embed type="text/html" src="snippet.html" width="500" height="200">
Example 3:
<embed type="video/webm" src="video.mp4" width="400" height="300">
34