Set - 1

Question 16 :

Do I have to memorize a bunch of tags?

Answer :

No. Most programs that help you write HTML code already know most tags, and create them when you press a button. But you should understand what a tag is, and how it works. That way you can correct errors in your page more easily.


Question 17 :

How do I make a form so it can be submitted by hitting ENTER?

Answer :

The short answer is that the form should just have one <INPUT TYPE=TEXT> and no TEXTAREA, though it can have other form elements like checkboxes and radio buttons.


Question 18 :

How do I set the focus to the first form field? 

Answer :

You cannot do this with HTML. However, you can include a script after the form that sets the focus to the appropriate field, like this:

<form id="myform" name="myform" action=...>
<input type="text" id="myinput" name="myinput" ...>
</form>

<script type="text/javascript">
document.myform.myinput.focus();
</script>

A similar approach uses <body onload=...> to set the focus, but some browsers seem to process the ONLOAD event before the entire document (i.e., the part with the form) has been loaded.


Question 19 :

How can I eliminate the extra space after a </form> tag?

Answer :

HTML has no mechanism to control this. However, with CSS, you can set the margin-bottom of the form to 0. For example: 
<p><form style="margin-bottom:0;" action=...></p>

You can also use a CSS style sheet to affect all the forms on a page:
form { margin-bottom: 0 ; }


Question 20 :

How can I use tables to structure forms?

Answer :

Small forms are sometimes placed within a TD element within a table. This can be a useful for positioning a form relative to other content, but it doesn't help position the form-related elements relative to each other. 
To position form-related elements relative to each other, the entire table must be within the form. You cannot start a form in one TH or TD element and end in another. You cannot place the form within the table without placing it inside a TH or TD element. You can put the table inside the form, and then use the table to position the INPUT, TEXTAREA, SELECT, and other form-related elements, as shown in the following example.

<form action="[URL]">
<table border="0">
<tr>
<th scope="row">
<label for="account">Account:</label>
</th>
<td>
<input type="text" name="account" id="account">
</td>
</tr>
<tr>
<th scope="row">
<label for="password">Password:
</th>
<td>
<input type="password" name="password" id="password">
</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Log On"></td>
</tr>
</table>
</form>