Professional Documents
Culture Documents
WDLecture 4 M I 25-10-2022
WDLecture 4 M I 25-10-2022
College Of Informatics
2022-2023
Lecture Four
Outline Of Lecture …..............................Four
1. Table
• Elements
• Attributes
• Spanning
• Page layout
2. Form?
• Form tag and its attributes
• Text input
• Password input
• Textarea input
• Control button
• Ratio button and checkbox button
• Drop down menu or list
• HTML5 inputs
• Date and time controls
• Numerical inputs
• Color selector
• Fieldset and legend
1
Table in HTML 2
<table>
<tr>
<th> Header 1 </th>
<td> Data1 </td>
</tr>
<tr> Header1 Data 1
<th> Header 2 </th> Header 2 Data 2
<td> Data 2 </td>
</tr>
This is the structure for 2
</table> row and 2 column
5
<table>
<tr>
<th> Header 1 </th>
<th> Header 2 </th>
</tr>
<tr>
<td> Data 1 </td>
<td> Data 2 </td> Header1 Header2
</tr>
Data1 Data2
<tr>
Data 3 Data 4
<td> Data 3 </td>
<td> Data 4 </td> This is a structure for a table
</tr> Which has 3 rows and 2 column
</table>
Minimal table structure 6
Let’s take a look at a simple table to see what it’s made of!
• Start and end table tags are used to identify the beginning and end of the
tabular material.
• The table element may directly contain only some number of tr (row)
elements
The caption tag will serve as a title or explanation for the table and
it shows up at the top of the table.
• The <caption> tag must be inserted immediately
after the <table> tag.
• You can specify only one caption per table.
• Syntax:
<table border=“1”>
<caption> table caption</caption>
<tr>
<td> data 2</td>
<td> data 2 </td>
</tr>
</table>
Spanning Cells 11
2. Row spans
Row spans, created with the rowspan attribute,work just like column
spans, but they cause the cell to span downward over several rows.
Some table attributes 13
Cell padding is the space inside the cell, between the content and
the edge of the cell.
<table cellpadding =“5”>
<table width=“100%”>
represent the same page size
<table width=“80%”>
represent the 80% page size
<td width=“50%”>
represent the 50% table size
•HTML Forms are one of the main points of interaction between a user and
a web site or application. They allow users to send data to the web site.
•Most of the time that data is sent to the web server, but the web page can
also intercept it to use it on its own.
•Most of the time those widgets are paired with a label that describes their
purpose.
•Properly implemented labels are able to clearly instruct both sighted and
blind users on what to enter into a form input.
What are HTML forms? 16
Forms allow us to build more dynamic websites that allow our users
to interact with it.
<form>
…
Form elements go here
...
</form>
Form attribute 17
✓ The action attribute specifies where to send the form- data when a form is
submitted
<form action=“ URL”>
Possible values:
• An absolute URL - points to another web site
(like action="http://www.example.com/example.htm")
This is the most commonly used tag within HTML forms.It allows you
to specify various types of user input fields such as text, radio buttons
, checkboxes etc.
✓ Text
Text fields are used for when you want the user to type short amounts
of text into the form.
<form>
First name: <input type="text" name="firstname">
Last name: <input type="text" name="lastname">
</form>
Text Input (type=“text”) 19
• You can create fields of other sizes by the value in the size option
• You can limit the number of characters by the value of the
maxlength option.
• Text input fields will be empty when the page loads, unless you
provide an initial text string for its value option
Syntax:
or
<input type="text" name="textfield" size=“value” value=”initial value">
Text Input (type=“text”) 20
A password field works just like a text entry field, except the
characters are obscured from view using asterisk (*) or bullet ()
or another character determined by the browser.
Example 5: A password field named "pass2" that is 30 characters wide but will
only accept 20 characters
A submit button:
<input type="submit" name="Submit" value="Submit">
A reset button:
<input type="reset" name="Submit2" value="Reset">
• Radio buttons are used for when you want the user to select only
one option from a pre-determined set of options.
• If you click one radio button, the others in the set are automatic
-ally de-selected
• The value sent in the web form is the value of the radio button that
was last selected
Radio buttons:<br>
<input type="radio" name=”gender" value="myValue1”>male
<br>
<input type="radio" name=“gender" value="myValue2" checked>
female
Checkboxes (type=“checkbox”) 27
• Are similar to radio buttons, but they enable the user to make
multiple selections.
• Note that every checkbox has a unique name. If there is no check
in the box☐, clicking it will place an or a check mark there
• If the box is checked, clicking it again will remove the mark. The
value sent in the web form is the value of the checkbox if it was s
elected; otherwise the value will be empty
A checkbox:
<input type=“checkbox” name=“checkbox”
value="checkbox" checked>
• type: “checkbox”
• name: used to reference this form element from JavaScript
• value: value to be returned when element is checked
• Note that there is no text associated with the checkbox—
you have to supply text in the surrounding HTML
Drop-down menu or list 29
A menu or list:
<select name="select">
<option value="red">red</option>
<option value="green">green</option>
<option value=“blue">blue</option>
</select>
Additional arguments:
– size: the number of items visible in the list (default is "1")
– multiple: if set to "true", any number of items may be selected (default is "false")
Grouping menu options 30
you can use the optgroup element to create conceptual groups of options.
The required label attribute in the optgroup element provides the heading
for the group.
<select name="icecream" size="7" multiple>
<optgroup label="traditional">
<option>vanilla</option>
<option>chocolate</option>
</optgroup>
<optgroup label="fancy">
<option>Super praline</option>
<option>Nut surprise</option>
<option>Candy corn</option>
</optgroup>
</select>
File upload 31
Web forms can collect more than just data. They can also be used to
transmit external documents from a user’s hard drive.
***Not all browsers support the new HTML5 input types or sup
port them in the same way, but the good news is that if the type is
n’t recognized, the default generic text input is displayed instead,
which works perfectly fine.***
Date and time controls (HTML5) 33
HTML5 introduced six new input types that make date and time
selection widgets part of a browser’s standard built-in display
capabilities
The new date- and time-related input types are as follows:
Date input control :
<input type="date" name="name" value="2017-02-08">
Time input control:
<input type="time" name="name" value="03:13:00">
Date/time control with time zone:
<input type="datetime" name="name" value="2004-01-14T03:1
3:00-5:00">
Date and time controls (HTML5) 34
Number input
<input type="number">
<input type="number" name=”semenar" min="1" max="6">
Slider input
<input type="range">
<input type="range" name="satis" min="0" max="10" step="1">
Color selector (HTML5) 36