|
HTML Lists
HTML supports ordered,
unordered and definition lists.
Unordered
Lists
An unordered list is a list of
items. The list items are marked with bullets (typically small
black circles).
An unordered list starts with
the <ul> tag. Each list item starts with the <li> tag.
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
|
Here is how
it looks in a browser:
Inside a list item you can put
paragraphs, line breaks, images, links, other lists, etc.
Ordered
Lists
An ordered list is also a list
of items. The list items are marked with numbers.
An ordered list starts with the
<ol> tag. Each list item starts with the <li> tag.
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
|
Here is how
it looks in a browser:
- Coffee
- Milk
Inside a list item you can put
paragraphs, line breaks, images, links, other lists, etc.
Definition
Lists
A definition list is not
a list of items. This is a list of terms and explanation of the
terms.
A definition list starts with
the <dl> tag. Each definition-list term starts with the <dt>
tag. Each definition-list definition starts with the <dd> tag.
<dl>
<dt>Coffee</dt>
<dd>Black hot drink</dd>
<dt>Milk</dt>
<dd>White cold drink</dd>
</dl>
|
Here is how
it looks in a browser:
- Coffee
- Black hot drink
- Milk
- White cold drink
Inside a definition-list
definition (the <dd> tag) you can put paragraphs, line breaks,
images, links, other lists, etc.
HTML Forms
and Input
HTML Forms are used to select
different kinds of user input.
Forms
A form is an area that can
contain form elements.
Form elements are elements that
allow the user to enter information (like text fields, textarea
fields, drop-down menus, radio buttons, checkboxes, etc.) in a
form.
A form is defined with the
<form> tag.
<form>
<input>
<input>
</form>
|
Input
The most used form tag is the
<input> tag. The type of input is specified with the type
attribute. The most commonly used input types are explained
below.
Text Fields
Text fields are used when you
want the user to type letters, numbers, etc. in a form.
<form>
First name:
<input type="text" name="firstname">
<br>
Last name:
<input type="text" name="lastname">
</form>
|
How it
looks in a browser:
Note that the form itself is
not visible. Also note that in most browsers, the width of the
text field is 20 characters by default.
Radio
Buttons
Radio Buttons are used when you
want the user to select one of a limited number of choices.
<form>
<input type="radio" name="sex" value="male"> Male
<br>
<input type="radio" name="sex" value="female"> Female
</form>
|
How it
looks in a browser:
Note that only one option can
be chosen.
Checkboxes
Checkboxes are used when you
want the user to select one or more options of a limited number
of choices.
<form>
<input type="checkbox" name="bike" value="yes">
I have a bike
<br>
<input type="checkbox" name="car" value="yes">
I have a car
</form>
|
How it
looks in a browser:
The Form's
Action Attribute and the Submit Button
When the user clicks on the
"Submit" button, the content of the form is sent to another
file. The form's action attribute defines the name of the file
to send the content to. The file defined in the action attribute
usually does something with the received input.
<form name="input" action="html_form_action.asp"
method="get">
Username:
<input type="text" name="user">
<input type="submit" value="Submit">
</form>
|
How it
looks in a browser:
If you type some characters in
the text field above, and click the "Submit" button, you will
send your input to a page called "html_form_action.asp". That
page will show you the received input.
Form Tags:
NN:
Netscape, IE: Internet Explorer
|
Start Tag |
NN |
IE |
Purpose |
|
<form> |
3.0 |
3.0 |
Defines a form for user input |
|
<input> |
3.0 |
3.0 |
Defines an input field |
|
<textarea> |
3.0 |
3.0 |
Defines a text-area (a multi-line text input control) |
|
<label> |
|
4.0 |
Defines a label to a control |
|
<fieldset> |
|
4.0 |
Defines a fieldset |
|
<legend> |
|
4.0 |
Defines a caption for a fieldset |
|
<select> |
3.0 |
3.0 |
Defines a selectable list (a drop-down box) |
|
<optgroup> |
6.0 |
|
Defines an option group |
|
<option> |
3.0 |
3.0 |
Defines an option in the drop-down box |
|
<button> |
|
4.0 |
Defines a push button |
|
<isindex> |
|
|
Deprecated. Use <input>
instead |
HTML Images
With HTML you can
display images in a document.
The Image
Tag and the Src Attribute
In HTML, images are defined
with the <img> tag.
The <img> tag is empty, which
means that it contains attributes only and it has no closing
tag.
To display an image on a page,
you need to use the src attribute. Src stands for "source". The
value of the src attribute is the URL of the image you want to
display on your page.
The syntax of defining an
image:
The URL points to the location
where the image is stored. An image named "boat.gif" located in
the directory "images" on
The browser puts the image
where the image tag occurs in the document. If you put an image
tag between two paragraphs, the browser shows the first
paragraph, then the image, and then the second paragraph.
The Alt
Attribute
The alt attribute is used to
define an "alternate text" for an image. The value of the alt
attribute is an author-defined text:
<img src="boat.gif" alt="Big Boat">
|
The "alt" attribute tells the
reader what he or she is missing on a page if the browser can't
load images. The browser will then display the alternate text
instead of the image. It is a good practice to include the "alt"
attribute for each image on a page, to improve the display and
usefulness of your document for people who have text-only
browsers.
Basic Notes
- Useful Tips
If an HTML file contains ten
images - eleven files are required to display the page right.
Loading images take time, so my best advice is: Use images
carefully.
Image Tags:
NN: Netscape, IE:
Internet Explorer
|
Start Tag |
NN |
IE |
Purpose |
|
<img> |
3.0 |
3.0 |
Defines an image |
|
<map> |
3.0 |
3.0 |
Defines an image map |
|
<area> |
3.0 |
3.0 |
Defines an area inside an image map |
Page 1
2 3
4 5 |