HTML List and Forms
HTML List 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.
<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>
<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>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type = "I">
<li>Beetroot</li>
</html>
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>
<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>
Form Attributes
Apart from common attributes, following is a list of the most frequently used form attributes
−
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
<head>
<body>
<form >
First name: <input type = "text" name = "first_name" />
<br>
Last name: <input type = "text" name = "last_name" />
</form>
</body>
</html>
Attributes
Following is the list of attributes for <input> tag for creating text field.
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
Attributes
Following is the list of attributes for <input> tag for creating password field.
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
<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>
Attributes
Following is the list of attributes for <textarea> tag.
1
name
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>
Attributes
Following is the list of attributes for <checkbox> tag.
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.
<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>
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.
<head>
<title>Select Box Control</title>
</head>
<body>
</html>
Attributes
Following is the list of important attributes of <select> tag −
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.
1
value
The value that will be used if an option in the select box box is selected.
3
label
An alternative way of labeling options
<head>
<title>File Upload Box</title>
</head>
<body>
<form>
<input type = "file" name = "fileupload" accept =
"image/*" />
</form>
</body>
</html>
Attributes
Following is the list of important attributes of file upload box −
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 −
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>
</html>
<head>
<title>File Upload Box</title>
</head>
<body>
<form>
<p>This is page 10</p>
<input type = "hidden" name = "pagename" value = "10" />
</html>
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