Lecture Notes-HTML Part 3
Lecture Notes-HTML Part 3
Learning Objectives:
• Understand Tags, Elements and Attributes
• Understand the basic Structure of HTML
• Text Elements
• Lists
• Article Tag
• Tables
• Embedded Content: image, Audio, video, links etc.
• Forms
• Meta Tag
• Layout
• Additional Tags
1. Forms: form elements are the basic building block of HTML page , this is the most common
elements that you will be using for any website development project that can be used to create contact
form, Newsletter form, Register or login form, personal information form
Forms are used to collect information from the user and post data to the script running on the server
(script on server can save data in database or file)
You can restrict data submit to the server and use different form elements to capture different type of
data from user
Basic Form Element:
<form> : form tag are used to define all form elements and into which users enter the data and submit
the data to the user
All form elements should be defined inside the <form> tag
Example: <body>
Label is used to enter some text before input field <form>
Input tag is used to define type of field using type <label for=” input-name”>First Name</label>
attribute <input id=” input-name” type=”text”
placeholder=” Enter your first name”>
placeholder: small text in the box to indicate what to
</form>
type.
</body>
1|Page
Input box form element:
<input> tag elements are used to display text boxes, submit buttons, email boxes and many other types
of form elements
2|Page
HTML offer different kinds of type values that can be used inside input tag each kind represent
different usage and output inside the form
<input id="name" type="text" placeholder="Enter your name">
3|Page
<input id="clear" type="reset"> Clear data in the form
<body>
<h1> Personal Information Form</h1>
<form>
<label for="fname"> First Name:</label>
<input id="fname" type="Text" placeholder="First Name Here"><br><br>
<label for="lname">Last Name:</label>
<input id="lname" type="text" placeholder="Last Name Here"><br><br>
<label for="phone"> Phone Number:</label>
<input id="phone" type="tel" placeholder="Your Phone Number"><br><br>
<label for="comment"> Comments</label>
<input id="comment" type="text" placeholder="Let us Know how you feel?"><br><br>
<input type="submit" id="btn">
<input type="reset" id="btn2">
</form> </body>
4|Page
Select Form Element:
<select> are used to show list of values that user can select from it like asking user to select one from
the option given
<select> <option> <optgroup>
Example1:
5|Page
Example2:
<body>
<h1>Show Checkboxes</h1>
<form action="#">
<input type="checkbox" id="vehicle1"
name="vehicle1" value="Bike">
<label for="vehicle1"> I have a bike</label><br>
<input type="checkbox" id="vehicle2"
name="vehicle2" value="Car">
<label for="vehicle2"> I have a car</label><br>
<input type="checkbox" id="vehicle3"
name="vehicle3" value="Boat">
<label for="vehicle3"> I have a
boat</label><br><br>
<input type="submit" value="Submit">
</form></body>
<body>
<h1> Text Area</h1>
<form>
<label for="gender">Comment</label>
<textarea cols="50" rows="5"></textarea>
</form>
</body>
7|Page
Action Get and Post from form
Method attribute of <form> tag explain how data should go when the form is submitted and they are
two types:
❖ Get
❖ Post
GET: parameters are appeared in the URL, used for fetching documents, retrieving data
POST: parameters are appeared in the body, used for updating data
Action: attribute that show the source that form will send after submission in the backend side
Meta Tag
Metadata Means data about data
<meta> tag describes about your page to the machines that are accessing your page
<meta> tag will help improve search engine optimization as it describes your page in such way that
search engine understand and learn about your page like keywords that help search engine to show
your page when these keywords are searched
Description: small description about your page
Robot help to communicate with search engine bots
All these tags are added inside head tag and not displayed on the browser you will not see anything on
the page.
<head>
<meta charset="UTF-8">
</head>
8|Page
Meta tag with viewport: scale zoom page on the browser (width, height, scaling)
Like
Meta tag with auto redirect: tell you can tell the browser to redirect the page to another after n seconds
<meta http-equiv="refresh" content="30; url=https://www.w3schools.com/tags/tag_meta.asp">
<body>
</body>
9|Page
<style>
.myDiv {
background-color: lightblue;
text-align: center;
</style>
</head>
<body>
<div class="myDiv">
</div>
10 | P a g e