0% found this document useful (0 votes)
140 views

HTML List and Forms

The document provides information about HTML lists and forms. It discusses the different types of lists (unordered, ordered, definition) and how to create them using <ul>, <ol>, and <dl> tags. It also covers the attributes used to customize lists, such as type, start, etc. Additionally, it describes the purpose of HTML forms and the main tags and attributes used to create forms like <form>, <input>, and action/method. It provides examples of different form controls like text, checkboxes, selects and how to implement them in HTML.

Uploaded by

Romnick
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
140 views

HTML List and Forms

The document provides information about HTML lists and forms. It discusses the different types of lists (unordered, ordered, definition) and how to create them using <ul>, <ol>, and <dl> tags. It also covers the attributes used to customize lists, such as type, start, etc. Additionally, it describes the purpose of HTML forms and the main tags and attributes used to create forms like <form>, <input>, and action/method. It provides examples of different form controls like text, checkboxes, selects and how to implement them in HTML.

Uploaded by

Romnick
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Module 4

HTML List and Forms


OBJECTIVES:
 Examine HTML List and Forms;
 identify different attributes used in HTML List and Forms; and
 create an HTML document using lists and forms.

COURSE CONTENT

HTML - Lists
HTML offers web authors three ways for specifying lists of information. All lists must
contain one or more list elements. Lists may contain
 <ul> − An unordered list. This will list items using plain bullets.
 <ol> − An ordered list. This will use different schemes of numbers to list your
items.
 <dl> − A definition list. This arranges your items in the same way as they are
arranged in a dictionary.

HTML Unordered Lists


An unordered list is a collection of related items that have no special order or
sequence. This list is created by using HTML <ul> tag. Each item in the list is
marked with a bullet.
Example
<!DOCTYPE html>
<html>

<head>
<title>HTML Unordered List</title>
</head>

<body>
<ul>
<li>Andy Lim</li>
<li>Bob Uy</li>
<li>Ara Yu</li>
<li>Sung Go</li>
<li>Aga Tuckey</li>
</ul>
</body>

</html>

Integrative Programming and Technologies 1


This will produce the following result −

The type Attribute


You can use type attribute for <ul> tag to specify the type of bullet you like. By
default, it is a disc. Following are the possible options −
<ul type = "square">
<ul type = "disc">
<ul type = "circle">
Example
Following is an example where we used <ul type = "square">
<!DOCTYPE html>
<html>

<head>
<title>HTML Unordered List</title>
</head>

<body>
<ul type = "circle">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</body>

</html>

This will produce the following result –

HTML Ordered Lists


If you are required to put your items in a numbered list instead of bulleted, then
HTML ordered list will be used. This list is created by using <ol> tag. The

Integrative Programming and Technologies 2


numbering starts at one and is incremented by one for each successive ordered list
element tagged with <li>.
Example
<!DOCTYPE html>
<html>

<head>
<title>HTML Ordered List</title>
</head>

<body>
<ol>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>

</html>

This will produce the following result −

The type Attribute


You can use type attribute for <ol> tag to specify the type of numbering you like. By
default, it is a number. Following are the possible options −
<ol type = "1"> - Default-Case Numerals.
<ol type = "I"> - Upper-Case Numerals.
<ol type = "i"> - Lower-Case Numerals.
<ol type = "A"> - Upper-Case Letters.
<ol type = "a"> - Lower-Case Letters.
Example
Following is an example where we used <ol type = "1">
<!DOCTYPE html>
<html>

<head>
<title>HTML Ordered List</title>
</head>

<body>
<ol type = "I">
<li>Beetroot</li>

Integrative Programming and Technologies 3


<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>

</html>

This will produce the following result −

The start Attribute


You can use start attribute for <ol> tag to specify the starting point of numbering
you need. Following are the possible options −
<ol type = "1" start = "4"> - Numerals starts with 4.
<ol type = "I" start = "4"> - Numerals starts with IV.
<ol type = "i" start = "4"> - Numerals starts with iv.
<ol type = "a" start = "4"> - Letters starts with d.
<ol type = "A" start = "4"> - Letters starts with D.

Example
Following is an example where we used <ol type = "i" start = "4" >
<!DOCTYPE html>
<html>

<head>
<title>HTML Ordered List</title>
</head>

<body>
<ol type = "i" start = "4">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>

</html>

This will produce the following result −

Integrative Programming and Technologies 4


HTML Definition Lists
HTML and XHTML supports a list style which is called definition lists where entries
are listed like in a dictionary or encyclopedia. The definition list is the ideal way to
present a glossary, list of terms, or other name/value list.
Definition List makes use of following three tags.

 <dl> − Defines the start of the list


 <dt> − A term
 <dd> − Term definition
 </dl> − Defines the end of the list
Example
<!DOCTYPE html>
<html>

<head>
<title>HTML Definition List</title>
</head>

<body>
<dl>
<dt><b>HTML</b></dt>
<dd>This stands for Hyper Text Markup Language</dd>
<dt><b>HTTP</b></dt>
<dd>This stands for Hyper Text Transfer Protocol</dd>
</dl>
</body>

</html>

This will produce the following result −

Integrative Programming and Technologies 5


HTML Forms
An HTML form is a section of a document containing normal content, markup, special
elements called controls (checkboxes, radio buttons, menus, etc.), and labels on those
controls. Users generally "complete" a form by modifying its controls (entering text, selecting
menu items, etc.), before submitting the form to an agent for processing (e.g., to a Web
server, to a mail server, etc.)
HTML Forms are required, when you want to collect some data from the site visitor. For
example, during user registration you would like to collect information such as name, email
address, credit card, etc.
There are various form elements available like text fields, textarea fields, drop-down menus,
radio buttons, checkboxes, etc.
The HTML <form> tag is used to create an HTML form and it has following syntax −
<form action = "Script URL" method = "GET|POST">
form elements like input, textarea etc.
</form>

Form Attributes
Apart from common attributes, following is a list of the most frequently used form attributes

Sr.N Attribute & Description


o

1 action
Backend script ready to process your passed data.

2 method
Method to be used to upload data. The most frequently used are GET and POST
methods.

3 target
Specify the target window or frame where the result of the script will be
displayed. It takes values like _blank, _self, _parent etc.

4 enctype
You can use the enctype attribute to specify how the browser encodes the data
before it sends it to the server. Possible values are −
application/x-www-form-urlencoded − This is the standard method most forms

Integrative Programming and Technologies 6


use in simple scenarios.
mutlipart/form-data − This is used when you want to upload binary data in the
form of files like image, word file etc.

HTML Form Controls


There are different types of form controls that you can use to collect data using HTML form

 Text Input Controls


 Checkboxes Controls
 Radio Box Controls
 Select Box Controls
 File Select boxes
 Hidden Controls
 Clickable Buttons
 Submit and Reset Button
Text Input Controls
There are three types of text input used on forms −
 Single-line text input controls − This control is used for items that require
only one line of user input, such as search boxes or names. They are created
using HTML <input> tag.
 Password input controls − This is also a single-line text input but it masks
the character as soon as a user enters it. They are also created using HTML
<input> tag.
 Multi-line text input controls − This is used when the user is required to
give details that may be longer than a single sentence. Multi-line input
controls are created using HTML <textarea> tag.

Single-line text input controls


This control is used for items that require only one line of user input, such as search
boxes or names. They are created using HTML <input> tag.
Example
Here is a basic example of a single-line text input used to take first name and last
name −
<!DOCTYPE html>
<html>

<head>

Integrative Programming and Technologies 7


<title>Text Input Control</title>
</head>

<body>
<form >
First name: <input type = "text" name = "first_name" />
<br>
Last name: <input type = "text" name = "last_name" />
</form>
</body>

</html>

This will produce the following result −

Attributes
Following is the list of attributes for <input> tag for creating text field.

Sr.N Attribute & Description


o

1
type
Indicates the type of input control and for text input control it will be set to text.

2
name
Used to give a name to the control which is sent to the server to be recognized
and get the value.

3
value
This can be used to provide an initial value inside the control.

4
size
Allows to specify the width of the text-input control in terms of characters.

5
maxlength
Allows to specify the maximum number of characters a user can enter into the

Integrative Programming and Technologies 8


text box.

Password input controls


This is also a single-line text input but it masks the character as soon as a user
enters it. They are also created using HTML <input>tag but type attribute is set
to password.
Example
Here is a basic example of a single-line password input used to take user password
This will produce the following result

Attributes
Following is the list of attributes for <input> tag for creating password field.

Sr.No Attribute & Description

1
type
Indicates the type of input control and for password input control it will be set
to password.

2
name
Used to give a name to the control which is sent to the server to be
recognized and get the value.

3
value
This can be used to provide an initial value inside the control.

4
size
Allows to specify the width of the text-input control in terms of characters.

5
maxlength
Allows to specify the maximum number of characters a user can enter into the

Integrative Programming and Technologies 9


text box.

Multiple-Line Text Input Controls


This is used when the user is required to give details that may be longer than a
single sentence. Multi-line input controls are created using HTML <textarea> tag.
Example
Here is a basic example of a multi-line text input used to take item description −
<!DOCTYPE html>
<html>

<head>
<title>Multiple-Line Input Control</title>
</head>

<body>
<form>
Description : <br />
<textarea rows = "5" cols = "50" name = "description">
Enter description here...
</textarea>
</form>
</body>

</html>

This will produce the following result −

Attributes
Following is the list of attributes for <textarea> tag.

Sr.N Attribute & Description


o

1
name

Integrative Programming and Technologies 10


Used to give a name to the control which is sent to the server to be
recognized and get the value.

2
rows
Indicates the number of rows of text area box.

3
cols
Indicates the number of columns of text area box

Checkbox Control
Checkboxes are used when more than one option is required to be selected. They
are also created using HTML <input> tag but type attribute is set to checkbox.
Example
Here is an example HTML code for a form with two checkboxes
<!DOCTYPE html>
<html>

<head>
<title>Checkbox Control</title>
</head>

<body>
<form>
<input type = "checkbox" name = "math" value = "on">
Math
<input type = "checkbox" name = "physics" value = "on">
Physics
</form>
</body>

</html>

This will produce the following result –

Attributes
Following is the list of attributes for <checkbox> tag.

Sr.N Attribute & Description


o

Integrative Programming and Technologies 11


1
type
Indicates the type of input control and for checkbox input control it will be
set to checkbox.

2
name
Used to give a name to the control which is sent to the server to be
recognized and get the value.

3
value
The value that will be used if the checkbox is selected.

4
checked
Set to checked if you want to select it by default.

Radio Button Control


Radio buttons are used when out of many options, just one option is required to be
selected. They are also created using HTML <input> tag but type attribute is set
to radio.
Example
Here is example HTML code for a form with two radio buttons −
<!DOCTYPE html>
<html>

<head>
<title>Radio Box Control</title>
</head>

<body>
<form>
<input type = "radio" name = "subject" value ="maths">
Maths
<input type = "radio" name = "subject" value ="physics">
Physics
</form>
</body>

</html>

This will produce the following result

Integrative Programming and Technologies 12


Attributes
Following is the list of attributes for radio button.

Sr.N Attribute & Description


o

1
type
Indicates the type of input control and for checkbox input control it will be
set to radio.

2
name
Used to give a name to the control which is sent to the server to be
recognized and get the value.

3
value
The value that will be used if the radio box is selected.

4
checked
Set to checked if you want to select it by default.

Select Box Control


A select box, also called drop down box which provides option to list down various
options in the form of drop-down list, from where a user can select one or more
options.
Example
Here is example HTML code for a form with one drop down box
<!DOCTYPE html>
<html>

<head>
<title>Select Box Control</title>
</head>

<body>

Integrative Programming and Technologies 13


<form>
<select name = "dropdown">
<option value = "Math" selected>Math</option>
<option value = "Physics">Physics</option>
</select>
</form>
</body>

</html>

This will produce the following result −

Attributes
Following is the list of important attributes of <select> tag −

Sr.N Attribute & Description


o

1
name
Used to give a name to the control which is sent to the server to be
recognized and get the value.

2
size
This can be used to present a scrolling list box.

3
multiple
If set to "multiple" then allows a user to select multiple items from the
menu.

Following is the list of important attributes of <option> tag −

Sr.No Attribute & Description

1
value
The value that will be used if an option in the select box box is selected.

Integrative Programming and Technologies 14


2
selected
Specifies that this option should be the initially selected value when the
page loads.

3
label
An alternative way of labeling options

File Upload Box


If you want to allow a user to upload a file to your web site, you will need to use a
file upload box, also known as a file select box. This is also created using the
<input> element but type attribute is set to file.
Example
Here is example HTML code for a form with one file upload box −
<!DOCTYPE html>
<html>

<head>
<title>File Upload Box</title>
</head>

<body>
<form>
<input type = "file" name = "fileupload" accept =
"image/*" />
</form>
</body>

</html>

This will produce the following result

Attributes
Following is the list of important attributes of file upload box −

Sr.N Attribute & Description


o

Integrative Programming and Technologies 15


1
name
Used to give a name to the control which is sent to the server to be
recognized and get the value.

2
accept
Specifies the types of files that the server accepts.

Button Controls
There are various ways in HTML to create clickable buttons. You can also create a
clickable button using <input>tag by setting its type attribute to button. The type
attribute can take the following values −

Sr.N Type & Description


o

1
submit
This creates a button that automatically submits a form.

2
reset
This creates a button that automatically resets form controls to their initial
values.

3
button
This creates a button that is used to trigger a client-side script when the
user clicks that button.

4
image
This creates a clickable button but we can use an image as background of
the button.

Example
Here is example HTML code for a form with three types of buttons −
<!DOCTYPE html>
<html>

<head>
<title>File Upload Box</title>
</head>

Integrative Programming and Technologies 16


<body>
<form>
<input type = "submit" name = "submit" value = "Submit"
/>
<input type = "reset" name = "reset" value = "Reset" />
<input type = "button" name = "ok" value = "OK" />
<input type = "image" name = "imagebutton" src =
“C:\Users\LENOVO\Desktop\Sample html\html logo.png" />
</form>
</body>

</html>

This will produce the following result

Hidden Form Controls


Hidden form controls are used to hide data inside the page which later on can be
pushed to the server. This control hides inside the code and does not appear on the
actual page. For example, following hidden form is being used to keep current page
number. When a user will click next page then the value of hidden control will be
sent to the web server and there it will decide which page will be displayed next
based on the passed current page.
Example
Here is example HTML code to show the usage of hidden control −
<!DOCTYPE html>
<html>

<head>
<title>File Upload Box</title>
</head>

<body>
<form>
<p>This is page 10</p>
<input type = "hidden" name = "pagename" value = "10" />

Integrative Programming and Technologies 17


<input type = "submit" name = "submit" value = "Submit"
/>
<input type = "reset" name = "reset" value = "Reset" />
</form>
</body>

</html>

This will produce the following result

TEACHING AND LEARNING ACTIVITIES


Activity:
Create a simple HTML document that uses all the discussed HTML list and forms.

REFERENCES
H., William (2011), HTML, CSS & JavaScipt Mobile Development for Dummies, John
Wiley & Sons, Inc., ISBN 978-1-118-02622-9
Ducket, J., (2011), HTML&CSS design and build websites, John Wiley & Sons, Inc., ISBN
978-1-118-00818-8
https://www.w3schools.com/tags/default.asp
https://www.tutorialspoint.com/html/html_lists.htm

Integrative Programming and Technologies 18

You might also like