HTML: More about tables and HTML forms
More about Tables:
Specifying column spans and row spans
Table cells can span multiple columns and/or multiple rows. The columnspan (colspan) attribute tells the browser how many columns a data cell should use and the rowspan the number of rows. These two attributes are important if you want visually appealing tables.
Note that when you specify a colspan of more than one, you must omit a <td></td> for every column spanned in the row. When spanning rows, you omit a <td></td> for each row that is being spanned.
Specifying a table’s header, body and footer
You can specify a table’s header, body and footer using the <thead></thead> tags, <tbody></tbody> tags and <tfoot></tfoot> tags. The meanings of the three tags are as you might imagine: <thead></thead> specifies the header, <tbody></tbody> specifies the table’s body and <tfoot></tfoot> specifies the the table’s footer.
Adding table dividing lines using rules
Often you might wish to display borders between only some table rows or columns. HTML tables have a rules property that allows you to do just that. If you only wish to show lines between rows, you assign the value rows to the rules attribute. To show only lines between columns, you assign the value cols. If you don’t want any lines, you specify none as the value. If you want lines between columns and rows, you specify all for the rules attribute. You can also specify rules dividing a table’s major groupings (thead, tfoot and tbody elements) by assigning rules to the value groups.
More about HTML forms
Forms capture user input from HTML pages. Forms are composed of check boxes, radio buttons, menus, text boxes, text areas and buttons. Forms are probably familiar to you if you have ever submitted information over the Internet. First you complete the form‘s fields. Once completed, you click the submit button and submit the form. Your browser then sends the form’s data as name/value pairs to a remote server. The server receives the form’s data, which it processes and optionally returns a result.
The <form></form> tags define a form. The <form> opening tag contains an action attribute. In the action attribute, you place the URL to the server script that processes the form. A server script is a computer program dedicated to processing submitted form data. Common server scripting languages include Java, PHP, ASP, .NET, C and Perl. Server form processing is beyond the scope of this book; however, there are ample resources both online and in print about server form processing.
<form name=”myform” method=”post” action=”./mypath/my_script.php”>
The <form> tag also contains a name and method attribute. The method attribute specifies whether the form is sent using the Post or Get protocol. Like form processing, a complete explanation of the Post and Get protocols is beyond the scope of this book. Just know that the Post protocol places a form’s data in what’s called an HTTP header and sends it to a server.
The Get protocol places a form’s data directly in the URL and submits them to a server.
You place the various data entry fields between the <form> and </form> tags. Elements include input elements, labels, textarea elements and select elements. Input elements can have a type of check box, file, text, and password, submit or reset.
<input type=”text” name=”myTextBox” />