Frames Tables Forms HTML
Frames Tables Forms HTML
Tables provide a means of organising the layout of data A table is divided into rows and columns: these specify the cells of the table Cells can contain text, images, links, other tables... Tables can also be used for organising the layout of the web page itself.
Tables
<table> <tr> main element table row
<th>
<td>
table header
table data
<table border="1"> <tr> <th>Name</th> <th>Course</th> <th>Year</th> </tr> <tr> <td>A B Morgan</td> <td>Fishing</td> <td>5</td> </tr> <tr> <td>D P Jones</td> <td>Sailing</td> <td>8</td> </tr> <tr> </table>
2
Tables
<table> <tr> main element table row
<th>
<td>
table header
table data
<table border="1"> <tr> <th>Name</th> <td>A B Morgan</td> <td>D P Jones</td> </tr> <tr> <th>Course</th> <td>Fishing</td> <td>Sailing</td> </tr> <tr> <th>Year</th> <td>8</td> <td>5</td> </tr> <tr> </table>
3
<table border="1"> <tr> <th colspan="2">Name</th> <th>Course</th> <th>Year</th> </tr> <tr> <td>A B</td> <td>Morgan</td> <td rowspan="2">Fishing</td> <td>5</td> </tr> <tr> <td>D J</td> <td>Jones</td> <td>Sailing</td> <td>8</td> </tr> <tr> </table>
4
The width attribute determines the width of the row relative to the table
BSc CM0133 Internet Computing
Table attributes
Table attributes
align alignment relative to the page width in pixels or percentage of page width border - width of border (pixels) cellspacing separation between cells (pixels) cellpadding - space around data inside cell (pixels) bgcolor - background colour (inside cells)
Table attributes
<table border="3" align="center" cellspacing="6" cellpadding="6" bgcolor="cyan"> <caption> <h2>Course Data</h2> </caption> <tr> <th>Name</th> <th>Course</th> <th>Year</th> </tr> <tr> <td>A B Morgan</td> <td>Fishing</td> <td>5</td> </tr> <! etc -->
BSc CM0133 Internet Computing 7
Page formatting
Tables can be used to organise the layout of the web page itself
</body> <table border="0" cellspacing="10"> <tr> <td> <img src="cat.gif" alt="cat"> <ul> <li>cats</li> <li>dogs</li> <li>butterflies</li> </ul> </td> <td> This piece of text illustrates the idea of placing two columns of information in a web page... Note also that there is no border in this table. </td> </tr> </table> </body>
8
Framesets
<html> <head><title>Frames 1</title></head> <frameset cols="140,*"> <frame name="navF" src="navigation.html"> <frame name="mainF" src="intro.html"> </frameset> </html> The frameset element replaces the body element frameset has attributes cols or rows, defined in terms of pixels, percentage(%) or unspecified (*) this splits the window into two or more columns or rows
BSc CM0133 Internet Computing 10
Frame attributes
<frameset cols="140,*"> <frame name="navF" src="navigation.html"> <frame name="mainF" src="intro.html"> </frameset>
The name attribute uniquely identifies the frame. It may be used as the target in an anchor (<a>) element
The src attribute specifies the web page to be placed in the frame initially (it may subsequently be overwritten)
The scrolling attribute ("auto", "yes", "no") specifies whether the frame is to have scroll bars The frameborder attribute ("0", "1") specifies whether the frame is to have a border
BSc CM0133 Internet Computing 11
navigation.html
The anchor tag has a target attribute
takes the name of the frame used to display the information
12
intro.html
A simple document which is initially placed in the "mainF" frame
Nested framesets
<html> <head><title>Frames 2</title></head> <frameset cols="140,*"> <frame name="navF" src="navigation.html"> <frameset rows="30%,70%"> <frame name="upperF" src="intro.html"> <frame name="lowerF" src="course.html"> </frameset> </frameset> </html>
14
Noframes
Some browsers cannot process frames. Alternative content should be provided using the noframes element
<html> <head><title>Frames 1</title></head> <frameset cols="140,*"> <frame name="navF" src="navigation.html"> <frame name="mainF" src="intro.html"> </frameset> <noframes> <body> Something here for browsers not supporting frames </body> </noframes> </html>
BSc CM0133 Internet Computing 15
Forms
Forms are user interfaces for data input Main application: to provide user input for programs and databases located on a web server local (client-side) scripts associated with the form Server-based programs may return data to the client as a web page Client-side scripts can read input data To validate the data, prior to sending to server To use in local processing which may output web page content that is displayed on the client
BSc CM0133 Internet Computing 16
Example applications
Questionnaires to provide feedback on a web site e-commerce, to enter name, address, details of purchase and credit-card number
request brochures from a company make a booking for holiday, cinema etc. buy a book, cd, etc obtain a map giving directions to a shop
Run a database query and receive results (an important part of e-commerce)
17
Input types
text checkbox radio (buttons) select (options) textarea password button submit reset hidden file image
18
Do you want to receive any further information:<br> <input type="button" name="yes" value=" Yes "> <input type="button" name="no" value=" No "><br>
23
clicking this button sends the form data to the program (URL) specified in the action attribute of the form
type="reset" clicking this button clears all data entered so far
Thank you<br> <input type="submit" name="send" value="Send"> <input type="reset" name="clear" value="Clear"><br>
BSc CM0133 Internet Computing 24