Tuesday, March 3, 2009
introduction to HTML
What is HTML
* Hyper is the opposite of linear. It used to be that computer programs had to move in a linear fashion. This before this, this before this, and so on. HTML does not hold to that pattern and allows the person viewing the World Wide Web page to go anywhere, any time they want.
* Text is what you will use. English letters, just like you use everyday..
* Markup is what you will do. You will write in plain English and then mark up what you wrote.
* Language. Some may argue that technically html is a code, but you write html in plain, everyday English language.
HTML is the code behind your webpage and is what your browser looks for to display a webpage, the way the webdesigner intended it to look, and is a series of tags
Keep this in mind: HTML documents must be text only.
When you save a HTML document, you must save only the text, nothing else. HTML browsers can only read text. Look at your keyboard. See the letters and numbers and little signs like % and @ and *? There are 128 in all (read upper- and lowercase letters as two). That's text. That's what the browser reads. It simply doesn't understand anything else.
Remember that if you are using Notepad, Wordpad, or Simple Text, the document will be saved as text with no extra prompting. Just choose SAVE.
If you are going to start learning to write HTML, it is a good idea to learn to look at other authors' HTML pages. The actual html potion of the page behind the pretty page you see in front of you now.
Looking at another's html code helps you learn how things are done and you can copy the style of pages that you like. Please do not just steal and copy the pages, but no one will be upset if you make the style in much the same way. For example, if you were going to build a house, you would look around to see what styles you like before deciding on your own design. Same thing here, look around the web and see what styles you like and apply them to your own ideas.
Here's how you look at an HTML document (known as the "source code")
* When you find a page you like, click on VIEW at the top of the screen.
* Choose SOURCE from the menu.
* The HTML document will appear on the screen.
Try it with this page. Click on VIEW and then choose the SOURCE.
It will look like mumbo jumbo right now, but soon it'll be readable and you'll be able to find exactly how a certain HTML presentation was performed.
What are HTML Tags?
HTML works in a very simple, very logical, format. It reads like you do, top to bottom, left to right. HTML is written with TEXT. What you use to set certain sections apart as bigger text, smaller text, bold text, underlined text, is a series of tags.
Think of tags as commands. For example if you want a line of text to be bold. You will put a tag at the exact point you want the bold lettering to start
All tags that are opened must correspondingly be closed, just as if you are writing a quoted statement with those "inverted commas". A tag is closed this way therefore we open a new tag
Basic HTML Tags
* A tag is a method of formatting HTML documents.
* With tags you can create italic or bold characters, make things blink, and can control the color and size of the lettering.
* Tags can be "nested". This means that you can make something bold and italic and green and blinking by simply surrounding the previous tag with the next.
* Tags can be used to insert pictures and graphics.
* Tags can be used to create bulleted lists like this one, or numbered lists.
* Tags look something like this: chosen text .
* All tags use the < and > (less-than and greater-than symbols) to signal the browser. These are located above the comma and period keys.
* Within a tag, capitalization doesn't matter. FONT is the same as font or Font . I usually don't bother capitalizing when I use tags. Below, I have used capital letters when I felt that the number "1" and the letter "l" might be confused.
* It is essential to always close the tags! If not, the formatting will contaminate everything that follows it. But don't panic, closing tags is very easy, and even the most experienced surfers sometimes forget.
Italics
To make italics surround the chosen text with these tags:
chosen text
The "/i" tag is essential; this will close the tag and stop the italics. If this is not done, all the text which follows the first, i , tag will appear italicized.
Bold Lettering
To make letters bold surround the chosen text with these tags:
chosen text
The "/b" tag is essential; this will close the tag and stop the bold lettering. If this is not done, all the text which follows the first, b , tag will appear in bold.
Changing Font Size
There are three different ways to change the size of the font. Method 1, Method 2, and Method 3.
Also see below on how to change both the size and the color of the font at the same time.
1. The first method is to use the "big" and "small" tags.
For example, to increase the font by one degree surround the text with the following tags:
chosen text
If you want to make it even bigger, you surround it again:
chosen text
To make the font small, surround it with the small tag:
chosen text
If you want to make it even smaller, surround it with the tag again:
chosen text
The "/big" and "/small" tags are essential; they will close the tag and stop the special formatting. If this is not done, all the text which follows the first, or , tag will appear in the altered size.
2. The second method is to directly change the font size.
You can use + and - along with a number to shrink and grow the font:
chosen text
chosen text .........(same as )
chosen text .........(plain text)
chosen text .........(same as )
chosen text
Notice that when you get to larger fonts they tend to appear bold.
The " /font " tag is essential; it will close the tag and define the end of the specialized formatting. If this is not done, all the text which follows the first, font size= , tag will appear in the altered size.
3. The third method is to use what are called headers.
Headers are abbreviated with the letter "h" and a number from 1 to 6. For example:
chosen text
Along with the tag, I will demonstrate the result for each:
chosen text
chosen text
chosen text
chosen text
chosen text
chosen text
Notice that the header method also utilizes a bold font.
The "/h# " tag is essential; it will close the tag and define the end of the specialized formatting. If this is not done, all the text which follows the first,
Blinking Text
To make text blink surround the chosen text with these tags:
Note: This will not show up if you are using Microsoft Explorer (Blame it on Bill Gates!).
The "/blink" tag is essential; this will close the tag and signal the end of the special formatting. If this is not done, all the text which follows the first,
Text Formating tags
Text formatting, in html terms, is when you give the browser instructions on how your text should look. These instructions come in the form of tags, and you'll learn these now.
Colour
You can specify which colour you want to use for all the text on your web page. The browser default is black, so you only really need to specify a colour if you don't want black. Here's how to do it.
*
Start your HTML Editor
*
Click File > New
*
Set a background colour and click OK
*
When you see the code, locate the first BODY tag
*
Click your cursor after the "Y" of BODY
*
Press the spacebar on your keyboard
*
Type in TEXT =
*
Then type a colour for your text
*
In between the two BODY tags, start typing you text
*
Save your web page, and then view the results
*
In the code below, the text has been set to Blue
If all you want to do is to change the colour of some text between the BODY tags, your HTML editor has a quick way of doing that.
*
Highlight the text whose colour you want to change
*
From the menu bar, click on Format > Text Colour
*
The Colour dialogue box appears
*
Choose a colour by clicking on a colour square
*
Click OK
Headings
You've already met the Headings tag. If you'll remember, the Heading tag uses the letter "H" followed by a number. Like this:
My Heading
or like this:
My Heading
The heading tag increases or decreases text size above or below the default size. The default size is 3. The biggest size is 1, and the smallest 7.
The heading tag will automatically insert a line break for you, so you don't have to insert a
or
tag after it to start a new line.
To insert a Heading tag with the HTML Editor, click on Insert > Heading then choose a Heading size. Only size 1 to 4 are used in the editor. But bear in mind, you can go as low as size 7.
When you click on a heading size, the beginning and end Tag will be inserted with the cursor flashing between the two:
The forward slash, remember, tells the browser to stop formatting a tag. In this case, stop formatting the H1 heading tag.
With the cursor flashing between the two tags, type your text for the heading.
Centring Text
To centre text (and anything else on your page), the CENTER tag is used. Note the American spelling, with "ER" at the end and not "RE". To centre something with the HTML Editor, do the following:
*
Highlight whatever you want to centre
*
From the menu bar, click on Format > Centre
*
The two CENTER tags will surround your highlighted text
*
Save your work and view the results in your browser
In this lesson, we'll continue our look at the basic text formatting tags available to you in HTML
Bold Text
You can make text stand out by using the bold tag.
*
In your Editor, highlight the text you want to make bold
*
From the menu bar, click on Format > Bold
*
The two tags will surround your highlighted text
*
Save your work and view the results in your browser
Bold Text
Italics
The HTML tag to make text italic is as simple as the "B" tag for bold text. With your HTML editor, do the following:
*
Highlight the text for the italics
*
From the menu bar, click on Format > Italics
*
The two tags will surround your highlighted text
*
Save your work and view the results in your browser
Subscript
Subscript is text that appears below normal text. Like this:
50p
You can have Subscript in your HTML code quite easily. To format text as subscript using your HTML editor, do this:
*
Highlight the text you want to turn into subscript
*
From the menu bar, click on Format > Subscript
*
The two tags will surround your highlighted text
*
Save your work and view the results in your browser
Superscript
Superscript is text that is raised slightly above the centre. Like this
24th
To format text as superscript using your HTML editor, do this:
*
Highlight the text you want to turn into superscript
*
From the menu bar, click on Format > Superscript
*
The two tags will surround your highlighted text
*
Save your work and view the results in your browser
PRE tag
The HTML pre tags are used to define the HTML pre element. The HTML pre element begins with the HTML
tag and ends with the HTMLtag. The HTML pre element is used to direct the browser to display a section of text exactly as it is typed with spaces and line feeds included.
HTML Pre Element Attributes
HTML "pre" element attributes include:
* width - (Depreciated). The "width" attribute specifies the number of characters across the screen to display. This is very rarely used. An example of its use is blockquote width="20"
* class - The class attribute is used in conjunction with style sheets to associate an element with a class. The class attribute can set a class for specific element types or it can be independent of element types and work for all elements. The class attribute will provide the settings for specific style formatting. CSS properties are shown at the CSS Properties page.
* ID - The ID attribute is used to apply style settings to specific individual HTML elements.
* style - The style attribute is used to apply style settings for the specific element the style attribute is included with. An example is"
- This sets the style or color of the text. This statement starts a paragraph with color, green:
. The STYLE attribute is common to most HTML elements (See the CSS Properties page).
* title - Used to give specific elements a title which may appear as a tooltip in some browsers when the mouse is held at or near the element.
HTML Pre Element Contents
The HTML pre element may contain other inline elements except "img", "object", "applet", "big", "small", "sub", sup". "font", and "basefont". HTML inline elements are listed at the HTML Inline Elements.
HTML Pre Element Inside
The HTML pre element can be contained inside the elements "applet", "blockquote", "body", "button", "center", "del", "dd", "div", "fieldset", "form", "iframe", "ins", "li", "map", "noframes", "noscript", "object", "td", and "th".
HTML Pre Element Use Example
The PRE element is handy for showing program code or part of file content as in this example:
switch ( )
{
case condition1
break;
case condition2
break;
}
This is how it looks:
switch ( )
{
case condition1
break;
case condition2
break;
}
CODE tag
An HTML code example cannot use the HTML delimiters < and >, because they will be executed by the browser as real HTML code. Rather you must substitute a < for the < and a > for the >.
Usually, the display font appearance for the code, kbd, samp, and tt tags is the same for a specific browser.
The pre tag is more commonly used to display code.
The separate closing tag is mandatory.
Attributes and Events
class dir id lang onclick ondblclick onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup style title
KBD tag
See also: code, font, plaintext, pre, samp, tt, var
Attributes
The kbd tag does not have any required HTML attributes. It does, however have numerous allowable attributes including:
* HTML Core Attributes
o class (type: CDATA) - space separated list of classes
o id (type: ID) - document-wide unique id
o style (type: Style Sheet) - associated style information
o title (type: Text) - advisory title/amplification; this information is usually displayed through tooltips
* HTML International Attributes (I18N)
o dir (type: Custom) - specifies the direction of weak or neutral text; valid values include ltr (left to right) or rtl (right to left)
o lang (type: Custom) - specifies the Language Code of the language used in the text
* HTML Event Attributes
o onclick (type: Script) - a pointer button was clicked
o ondblclick (type: Script) - a pointer button was double clicked
o onkeydown (type: Script) - a key was pressed down
o onkeypress (type: Script) - a key was pressed and released
o onkeyup (type: Script) - a key was released
o onmousedown (type: Script) - a pointer button was pressed down
o onmousemove (type: Script) - a pointer was moved within
o onmouseout (type: Script) - a pointer was moved away
o onmouseover (type: Script) - a pointer was moved onto
o onmouseup (type: Script) - a pointer button was released
Usage
To use the kbd tag, simply place opening and closing HTML tags around the characters that should be entered by the user. For example:
To destroy the usefulness of your computer, type del C:\*.* /S /Q at the command prompt.
On browsers that support this tag, this will typically cause the phrase "del *.* /S /Q" to be displayed in a monospaced font. Keep in mind that the purpose of this tag is to specify text to be typed in by the user, not to format your text. If you simply want to use a teletype font, you should technically use Cascading Style Sheets or the pre tag, however there are also the deprecated plaintext, samp, and tt tags that will do this as well.
SAMP tag
For many browsers, the display font appearance for the code, kbd, samp, and tt tags is the same.
The separate closing tag is mandatory.
Attributes and Events
class dir id lang onclick ondblclick onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup style title
TT tag
Usually, the display font appearance for the code, kbd, samp, and tt tags is the same. The listing tag has been deprecated.
The closing tag is mandatory.
Core attributes:
class dir id lang onclick ondblclick onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup style title
PLAINTEXT tag
Example code:
An example of how the
XMP tag
The XMP Tag ID's aren't listed because in most cases they are identical to the Tag Name.
All XMP information is stored as character strings. The Writable column specifies the information format: string is an unformatted string, integer is a string of digits (possibly beginning with a '+' or '-'), real is a floating point number, rational is entered as a floating point number but stored as two integer strings separated by a '/' character, date is a date/time string entered in the format "YYYY:MM:DD HH:MM:SS[.SS][+/-HH:MM]", boolean is either "True" or "False", and lang-alt is a list of string alternatives in different languages.
Individual languages for lang-alt tags are accessed by suffixing the tag name with a '-', followed by an RFC 3066 language code (ie. "XMP:Title-fr", or "Rights-en-US"). A lang-alt tag with no language code accesses the "x-default" language, but causes other languages for this tag to be deleted when writing. The "x-default" language code may be specified when writing to preserve other existing languages (ie. "XMP-dc:Description-x-default"), but note that other languages are still deleted if the "x-default" language is deleted. When reading, "x-default" is not specified.
The XMP tags are organized according to schema Namespace in the following tables. Note that a few of the longer namespace prefixes given below have been shortened for convenience (since the family 1 group names are derived from these by adding a leading "XMP-"). In cases where a tag name exists in more than one namespace, less common namespaces are avoided when writing. However, any namespace may be written by specifying a family 1 group name for the tag, ie) XMP-exif:Contrast or XMP-crs:Contrast.
ExifTool will extract XMP information even if it is not listed in these tables. For example, the pdfx namespace doesn't have a predefined set of tag names because it is used to store application-defined PDF information, but this information is extracted by ExifTool.
ADDRESS tag
Table of contents
* Description
* Attributes
* Events
* Examples
Description
The HTML address tag is commonly used to provide contact information at the bottom or beginning of a document or a form. It could be used, for example, to provide information about the enterprise behind the website, the author of a specific article or the author of the website itself. Note that browsers may change the aspect of the text between these tags (e.g., italic font).
Attributes
id (name)
The "id" attribute assigns an identifier to the associated element. This identifier must be unique in the document and can be used to refer to that element.
Example:
Code begin
This is the first paragraph named as paragraph1. To dynamically change its properties use this identifier.
Code endclass (cdata)
The "class" attribute assigns a class name (or a list of class names separated by spaces) to the container element. It's used with style sheets and tells the browser the class to which the element is associated with. A class gives visual attributes to elements.
Example:
Code begin
This article is based on the book "Wind in the trees" by Jhon L. Brooks
This article is based on the book "Wind in the trees" by Jhon L. Brooks... and is more important than the one before.
Code endstyle (style)
Defines a visual style of this element. Is a better practice to define styles attributes in external style sheets grouping them in classes. Attributes in the "style" parameter must preserve this order "name : value" and be separated by a semi-colon.
If you're writing XHTML code it's recommended not to use this attribute and try style sheet classes (with the "class" attribute).
Example:
Code begin
This is a paragraph with a defined style
And this is another text without style.
Code endtitle (text)
Indicates a title for the element. Used to give a short description about the element that is usually shown as a "tool tip" when the user put the mouse pointer over the element.
Example:
Code View
HTML code HTML code
lang (langcode)
Specifies the language of an element's content. The default value in "unknown".
When writing XHTML code the syntax "xml:lang" represents a preferred alternative in XHTML 1.0 and a replacement in XHTML 1.1 (e.g., xml:lang="en").
Example:
Code begin
This is a paragraph in english.
Este es un párrafo en español.
Code enddir
Specifies the text direction of the element's contents and attribute values, as well as tables directionality. It has two possible values that are case insensitive:
* RTL: Right to left.
* LTR: Left to right.
Example:
Code begin
...a Hebrew quotation...
Code endEvents
* onclick
* ondblclick
* onmousedown
* onmouseup
* onmouseover
* onmousemove
* onmouseout
* onkeypress
* onkeydown
* onkeyup
See complete list and information about events in HTML
Events in HTML
As well as attributes, events can be defined in HTML tags. Events, instead of giving values to the elements like the attributes, trigger actions when they occurs. These actions are defined by client-side scripts that are programs written to perform some action in a specific language (e.g., JavaScript, VBScript, etc.). There are different events that occurs in different instances according to browsers or users actions.
List of events
Below is al list of all events available for the HTML 4.01 Standard.
* onload: The onload event occurs when the user agent finishes loading a window or all frames within a frameset.
* onunload: The onunload event occurs when the user agent removes a document from a window or frame.
* onclick: The onclick event is triggered when the mouse button is clicked over the element.
* ondblclick: The ondblclick event occurs when the pointing device button is double clicked over an element.
* onmousedown: The onmousedown event is triggered when the mouse button is pressed over the element.
* onmouseup: The onmouseup event occurs when the pointing device button is released over an element.
* onmouseover: The onmouseover event is triggered when the mouse is moved onto the element.
* onmousemove: The onmousemove event occurs when the pointing device is moved while it is over an element.
* onmouseout: The onmouseout event is triggered when the mouse is moved away from the element.
* onfocus: The onfocus event occurs when an element receives focus either by the pointing device or by tabbing navigation.
* onblur: The onblur event is triggered when an element loses focus either by the pointing device or by tabbing navigation.
* onkeypress: The onkeypress event occurs when a key is pressed and released over an element.
* onkeydown: The onkeydown event is triggered when a key is pressed down over the element.
* onkeyup: The onkeyup event occurs when a key is released over an element.
* onsubmit: The onsubmit event is triggered when a form is submitted.
* onreset: The onreset event occurs when a form is reset.
* onselect: The onselect event is triggered when a user selects some text in a text field.
* onchange: The onchange event occurs when a control loses the input focus and its value has been modified since gaining focus.
BLOCKQUOTE tag
tag and ends with the HTMLtag. The HTML blockquote element is used to format a block of text as a long quote which is indented more than the surrounding text on the left and the right.
HTML Blockquote Element Attributes
HTML "blockquote" element attributes include:
* cite="uri" - Specifies the URI of the source of the quote.
* class - The class attribute is used in conjunction with style sheets to associate an element with a class. The class attribute can set a class for specific element types or it can be independent of element types and work for all elements. The class attribute will provide the settings for specific style formatting. CSS properties are shown at the CSS Properties page.
* ID - The ID attribute is used to apply style settings to specific individual HTML elements.
* style - The style attribute is used to apply style settings for the specific element the style attribute is included with. An example is"
- This sets the style or color of the text. This statement starts a paragraph with color, green:
. The STYLE attribute is common to most HTML elements (See the CSS Properties page).
* title - Used to give specific elements a title which may appear as a tooltip in some browsers when the mouse is held at or near the element.
HTML Blockquote Element Contents
The HTML blockquote element may contain other block elements such as headers, paragraphs, preformat blocks and tables. HTML block elements are listed at the HTML Block Elements. The HTML "blockquote" element may also contain the "script" element.
HTML Blockquote Element Inside
The HTML blockquote element can be contained inside the elements "applet", "blockquote", "body", "button", "center", "del", "dd", "div", "fieldset", "form", "iframe", "ins", "li", "map", "noframes", "noscript", "object", "td", and "th". The HTML "blockquote" element should not be contained inside a paragraph element.
HTML Blockquote Element Use Example
This is the HTML code:
The preamble of the Constitution says:
We the People of the United States, in Order to form a more perfect Union, establish Justice, insure domestic Tranquility, provide for the common defence, promote the general Welfare, and secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish this Constitution for the United States of America.
This is how it looks:
The preamble of the Constitution says:
We the People of the United States, in Order to form a more perfect Union, establish Justice, insure domestic Tranquility, provide for the common defence, promote the general Welfare, and secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish this Constitution for the United States of America.
CITE tag
It is recommended that you use the blockquote tag for long citations and the cite tag for short citations.
The closing tag is mandatory.
Core Attributes
class dir id lang onclick ondblclick onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup style title
DFN tag
Table of contents
* Description
* Attributes
* Events
* Examples
Description
The HTML dfn tag indicates that this is the defining instance of the term enclosed by the tags.
Attributes
id (name)
The "id" attribute assigns an identifier to the associated element. This identifier must be unique in the document and can be used to refer to that element.
Example:
Code begin
This is the first paragraph named as paragraph1. To dynamically change its properties use this identifier.
Code endclass (cdata)
The "class" attribute assigns a class name (or a list of class names separated by spaces) to the container element. It's used with style sheets and tells the browser the class to which the element is associated with. A class gives visual attributes to elements.
Example:
Code begin
This article is based on the book "Wind in the trees" by Jhon L. Brooks
This article is based on the book "Wind in the trees" by Jhon L. Brooks... and is more important than the one before.
Code endstyle (style)
Defines a visual style of this element. Is a better practice to define styles attributes in external style sheets grouping them in classes. Attributes in the "style" parameter must preserve this order "name : value" and be separated by a semi-colon.
If you're writing XHTML code it's recommended not to use this attribute and try style sheet classes (with the "class" attribute).
Example:
Code begin
This is a paragraph with a defined style
And this is another text without style.
Code endtitle (text)
Indicates a title for the element. Used to give a short description about the element that is usually shown as a "tool tip" when the user put the mouse pointer over the element.
Example:
Code View
HTML code HTML code
lang (langcode)
Specifies the language of an element's content. The default value in "unknown".
When writing XHTML code the syntax "xml:lang" represents a preferred alternative in XHTML 1.0 and a replacement in XHTML 1.1 (e.g., xml:lang="en").
Example:
Code begin
This is a paragraph in english.
Este es un párrafo en español.
Code enddir
Specifies the text direction of the element's contents and attribute values, as well as tables directionality. It has two possible values that are case insensitive:
* RTL: Right to left.
* LTR: Left to right.
Example:
Code begin
...a Hebrew quotation...
Code endEvents
* onclick
* ondblclick
* onmousedown
* onmouseup
* onmouseover
* onmousemove
* onmouseout
* onkeypress
* onkeydown
* onkeyup
See complete list and information about events in HTML
Events in HTML
As well as attributes, events can be defined in HTML tags. Events, instead of giving values to the elements like the attributes, trigger actions when they occurs. These actions are defined by client-side scripts that are programs written to perform some action in a specific language (e.g., JavaScript, VBScript, etc.). There are different events that occurs in different instances according to browsers or users actions.
List of events
Below is al list of all events available for the HTML 4.01 Standard.
* onload: The onload event occurs when the user agent finishes loading a window or all frames within a frameset.
* onunload: The onunload event occurs when the user agent removes a document from a window or frame.
* onclick: The onclick event is triggered when the mouse button is clicked over the element.
* ondblclick: The ondblclick event occurs when the pointing device button is double clicked over an element.
* onmousedown: The onmousedown event is triggered when the mouse button is pressed over the element.
* onmouseup: The onmouseup event occurs when the pointing device button is released over an element.
* onmouseover: The onmouseover event is triggered when the mouse is moved onto the element.
* onmousemove: The onmousemove event occurs when the pointing device is moved while it is over an element.
* onmouseout: The onmouseout event is triggered when the mouse is moved away from the element.
* onfocus: The onfocus event occurs when an element receives focus either by the pointing device or by tabbing navigation.
* onblur: The onblur event is triggered when an element loses focus either by the pointing device or by tabbing navigation.
* onkeypress: The onkeypress event occurs when a key is pressed and released over an element.
* onkeydown: The onkeydown event is triggered when a key is pressed down over the element.
* onkeyup: The onkeyup event occurs when a key is released over an element.
* onsubmit: The onsubmit event is triggered when a form is submitted.
* onreset: The onreset event occurs when a form is reset.
* onselect: The onselect event is triggered when a user selects some text in a text field.
* onchange: The onchange event occurs when a control loses the input focus and its value has been modified since gaining focus.
Saturday, February 28, 2009
IMAGE tag
The tag has two required attributes: src and alt.
The Image Tag and the Src Attribute
In HTML, images are defined with the tag.
The 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 "www.w3schools.com" has the URL: http://www.w3schools.com/images/boat.gif.
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:
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.
ANCHOR tag
on the Internet or to some anchor on the same page. Documents linked in this manner need not be HTML (or PHP/ASP) files. You can place a link to any kind of file.
Anchor Tag attributes
charset= text
Character encoding which specifies the character encoding of the target URL.
Example: charset=utf-8
href = relative address (i.e. the address of a file RELATIVE to the current document)
move up to next higher folder using ../
move down to a lower folder using folder (or 'directory' on the server) name
display from fragmentation-id position on document using #fragmentation-id.
Example-1: - current document displayed with fragmentation-id section at top of display. This is coding for moving round the same document, perhaps with an index at the top linking to sub-sections lower down.
Example-2: - file in current folder displayed with top of page at top of display. With no fragmentation id specified, the display is from the top of the page.
Example-3: - file in next highest folder is displayed with the top of the page at the top of the display.
Example-4: - a file in a lower folder is displayed with fragmentation-id at the top of the display.
href = absolute address
Example-5: - the server default file in directory at this absolute address is displayed from top of page.
Example-6: - specified file at this absolute address is displayed from top of page.
Example-7: - file with this absolute address is displayed from fragmentation-id position.
Example-8: - file (schedule.htm) with absolute address (http://www.bbc.com/radio4/) - is displayed from fragmentation-id position (#today) , and gives a fragmentation-id (refbbc) for the current position in the current document.
types of file
Normally the link is to another webpage (with file extension htm or html), but links to other file extensions are possible. An extensive variety of files can be accommodated, but the presumption is that the user has associated the file extension with a suitable application program, for example:
.doc associated with MS Word. .pdf associated with Adobe Reader. .ppt associated with MS Powerpoint.
Formats may include .wav for audio, .pdf / .doc for desktop publishing, .ppt for presentation, .exl for spreadsheet, etc. Consequently, only the most popular, legacy formats should be linked, in order to ensure that the majority of users' set-ups can deal with the format presented.
Note 1: A file-type icon is often added to the link for visual confirmation of a non-HTML link -
word minutes.doc estimates.exl excel
adobe acrobat instructions.pdf presentation.ppt adobe acrobat
Note 2: A link to a PDF format document is often accompanied by
adobe reader Link to Adobe Reader download
providing the user with a link to downloadable software, which can be used to view the file.
href = mailto (i.e. to send an e-mail)
Example: e-mail
Note 1: Minimise spam, frustrate the spambots by using coding to hide the e-mail address.
Note 2 : Make it clear that it is an e-mail link.
name= text
Example: - signifies a Fragmentation Identifier (anchor) position on the current document.
Note: a linking href must use a leading # after the document name (see Examples - 1,4,7,8)
further Fragmentation Identifier
The id attribute in the start tag of A (and other elements) identifies a reference position in the document. Name (or id) must be unique for the document. When linked using the fragmentation identifier, the browser shows the start of the fragment at the top of the display.
id=text
Example:
- signifies a fragmentation identifier position on the page.
Note: the linking href must use a leading # after the document name (see Examples - 1,4,7,8)
rel= text
Specifies the relationship between the current document and the target URL.
Example: rel=index
Options: alternate,designates,stylesheet,start,next,prev,contents,index,glossary,copyright, chapter,section,subsection,appendix,help,bookmark
rev= text
Specifies the reverse relationship between the document and the target URL
Example: rel=subsection
Options: alternate,designates,stylesheet,start,next,prev,contents,index,glossary, copyright,chapter,section,subsection,appendix,help,bookmark
target= text
Example: target="_blank" - retains 'stickability' and hence generally preferable.
Options: a href="URL" target="_blank" creates a new window of default size
a href="URL" target="_parent" targets the frameset in which the current page belongs
a href="URL" target="_self" targets the current window
a href="URL" target="_top" targets the main browser window, eliminating all frames
title= text
The text displayed when the mouse hovers over the text-link (mouse-over tool-tip).
Note: In the case of a graphic link (depending on the browser), the ALT attribute of the IMG tag may take precedence.
Example: title="Tool Tip displayed on hover" - when the mouse hovers over the link, a tool tip is displayed.
Mouseover Tool Tip
* an exciting description can encourage the user to investigate the link
* use to give extra information
Anchor Tag hypertext link
hypertext as text
Example: Anchor tag definition - SEs use linking text as keywords to categorise the content of the link. Decide which are the most appropriate keywords for the content and use them in the link text.
Link-text content
* One way to improve your Search Engine ranking.
* Carefully select appropriate, hypertext keywords within the website.
* Ask external link creators to use your own, selected, keyword-rich anchor-text in their external hypertext link.
Link-text appearance
* length can be controlled by incorporating the line return character
* change font characteristics using CSS (see below)
hypertext as graphic
Note 1: Always specify IMG attributes width, height, alt, border.
Note 2: According to the browser, with the Tool Tip the IMG, alt attribute may take priority over the A, title attribute.
Homepage Example:
- image is bordered by the link colour if border=0 is omitted.
Homepage Example:
- use border=0 to eliminate link-colour border to graphic.
Homepage
Home
Example:
Home
- a combination of graphic and text is often used to clearly identify the hyperlink.
Client-side mapping
By moving the cursor to different parts of the graphic, different links can be created.
See the IMG tag attribute usemap for further information.
Web link legacy and consistency
In the early days of the WWW, links were all coloured blue and underlined. Users still expect text of this colour to operate as a link, so to meet their expectations and to give them confidence when using the site, it is recommended that link text throughout the site is generally coloured blue.
Such a global feature should be coded in a Linked CSS stylesheet.
Dynamic link - styled attributes
To attract the user's attention, and to confirm that a hyperlink exists, it is always good policy to make the hypertext dynamic.
These sort of changes are particularly powerful for the navigation components, which could involve contrasts of the 'a hover' and 'a' css properties and values. However dynamic changes which could drastically affect nearby text and alter the layout (e.g. font-size) are not recommended.
Example:
Homepage
Home The style attributes for the link text and graphic can be selected so that a mouseover produces a dynamic change of appearance.
This graphic has a transparent background, with the 'white' background-color showing through.
On 'hover' the background-color changes from 'white' to 'purple' with the link-text font-color changing from 'blue' to 'orange'.
Note: IE produces the expected result, Firefox makes transparent only the lower half of the graphic.
Linked CSS style sheet Pseudo-class selectors
Currently these are: hover, active, link, visited, lang, focus
The first four are directly relevant to an anchor tag link.
A linked style sheet contains declarations of global properties and values.
Example:
a:link {color:#0000CC; text-decoration:none; font-weight: bold; }
a:active {color:#FF0000; text-decoration:none; }
a:visited {color:#660099; text-decoration:none; font-weight: bold; }
a:hover {color:#FF9900; text-decoration:none; background-color: white; }
Note: use of the COLON rather than the usual full stop.
Varied CSS link tags
In general, it is very confusing for the user if the link tags vary throughout the website, but in exceptional cases this may be required.
On a linked style sheet an alternative set of parameters could be defined for the anchor attributes.
Example:
a.exc:link {color:#0000CC; text-decoration:none; font-weight: bold; }
a.exc:active {color:#FF0000; text-decoration:none; }
a.exc:visited {color:#660099; text-decoration:none; font-weight: bold; }
a.exc:hover {color:#FF9900; text-decoration:none; background-color: purple; }
Notes:
* See above example in 'Dynamic link - styled attributes'. On 'hover' the background-color is 'purple' rather than the usual 'white', making 'hover' dynamic - on a white, transparent-background, graphical link.
* Coded using the class="exc" notation.
e.g.
Use CSS to change link characteristics
On rare occasions, it may be necessary to change locally, the global characteristics inherited from the linked stylesheet.
Change the static anchor-text attributes
The anchor-text can be changed within the anchor coding using CSS attributes.
This could involve:
color style="color:red;" font color
font-family style="font-family: times new roman;" font-family
font-weight style="font-weight: bold;" bold
font-style style="font-style: italic;" italic
font-size style="font-size: x-small;" x-small
text-decoration style="text-decoration: underline;" underline
background-color style="background-color: #ffccff;"
MAP tag
The name attribute is required in the map element. This attribute is associated with the 's usemap attribute and creates a relationship between the image and the map.
The map element contains a number of area elements, that defines the clickable areas in the image map.
Required Attributes
DTD indicates in which DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.
Attribute Value Description DTD
name mapname Specifies the name for an image-map STF
Standard Attributes
id, class, title, style, dir, lang, xml:lang, tabindex, accesskey
For a full description, go to Standard Attributes.
Event Attributes
onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup, onfocus, onblur
For a full description, go to Event Attributes.
AREA TAG
Das -Tag muss im MAP-Element enthalten sein. Das IMG-Element kann vor oder nach dem map-Tag, in dem die -Tags enthalten sind, stehen.
Für das -Tag können keine CSS-Eigenschaften notiert werden – AREA-Elemente sind nur maus-sensitive Bereiche, aber bilden keine Blöcke im Dokument.
Attribute für area
accesskey
bestimmt eine Taste auf der Tastatur, die beim Drücken zusammen mit der Alt-, Strg- oder Befehlstaste einen Link aktiviert.
alt
verknüpft einen Text mit einem individuellen Bereich der Map. Wenn die Maus über den Bereich fährt, stellt ein kleines Fenster diesen Text dar.
coords
legt die (x,y)-Koordinaten für jede Form in der Image Map fest. Die Koordinaten sind der x- und y-Abstand von der oberen linken Ecke (0,0) zum Bild. Die Anzahl der Koordinaten hängt von der Form ab, die im shape-Attribut definiert wird.
rect: top left bottom right
circle: center radius, wobei center als x,y-Paar angegeben wird
poly: Ecken des Polygons.
href
URL-Adresse eines Links. Jedes -Tag im Bild kann einen Link enthalten.
nohref
gibt an, dass der im -Tag definierte Bereich kein Link ist. Dann zeigen die Browser den Hot Spot der Image Map beim Hovern mit der Maus auch nicht mit einem entsprechenden Cursor und der Cursor kann auch nicht durch ein Stylesheet geändert werden.
shape
definiert die geometrische From der Image Map. Das kann entweder ein Kreis (circle oder circ), ein Polygon (polygon oder poly) oder ein Viereck (rectangle oder rect) sein.
tabindex
ganze Zahl, die den Rang innerhalb der Tabulatoraufrufe bei der Navigation mit der Tastatur festlegt.
TABLE TAG
row 1, cell 1 | row 1, cell 2 |
row 2, cell 1 | row 2, cell 2 |
How it looks in a browser:
row 1, cell 1 row 1, cell 2
row 2, cell 1 row 2, cell 2
Tables and the Border Attribute
If you do not specify a border attribute the table will be displayed without any borders. Sometimes this can be useful, but most of the time, you want the borders to show.
To display a table with borders, you will have to use the border attribute:
Row 1, cell 1 | Row 1, cell 2 |
Headings in a Table
Headings in a table are defined with the
Heading | Another Heading |
---|---|
row 1, cell 1 | row 1, cell 2 |
row 2, cell 1 | row 2, cell 2 |
How it looks in a browser:
Heading Another Heading
row 1, cell 1 row 1, cell 2
row 2, cell 1 row 2, cell 2
Empty Cells in a Table
Table cells with no content are not displayed very well in most browsers.
row 1, cell 1 | row 1, cell 2 |
row 2, cell 1 |
How it looks in a browser:
row 1, cell 1 row 1, cell 2
row 2, cell 1
Note that the borders around the empty table cell are missing (NB! Mozilla Firefox displays the border).
To avoid this, add a non-breaking space ( ) to empty data cells, to make the borders visible:
row 1, cell 1 | row 1, cell 2 |
row 2, cell 1 |
How it looks in a browser:
row 1, cell 1 row 1, cell 2
row 2, cell 1
Thursday, February 19, 2009
TR tag
Defines a row in a table. It is used within the TABLE tag. The TD tag is used within it to define a cell.
Attributes
ALIGN
Aligns the text for the cells in the row - set to either 'left', 'center', 'justify' or 'right'.
BACKGROUND
Sets the background picture for the cells in the row. To show to an image on the same site use the local path e.g. src="button.gif" or src="folder/photo1.jpg". You can also use dots to link to an image in the parent folder e.g. src="..\diagram.png".
BGCOLOR
Specifies the background colour of the cells in the row. If the BACKGROUND attribute is also used, the image will cover the background colour unless the background image contains transparent areas.
Colours can be defined in this format: #RRGGBB where the values are in hexadecimal format. E.g. #FF0000 is red. Colours can also be defined with words e.g. red.
VALIGN
Vertically aligns the text for the cells in the row - set to either 'baseline', 'bottom', 'middle' or 'top'.
TH tag
The td tag is used to create cells that contain the data, information, or text that you wish to display in the table.
The closing tag is optional. However, it is recommended that it always be included.
The coding sequence is:
Core attributes:
class dir id lang onclick ondblclick onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup style title
Attributes
abbr
The abbr attribute is not recognized by most browsers. You use it to provide an abbreviated summary of the header text.
align
The align attribute is used to set the horizontal alignment of the cell contents. The possible values are center, char, justify, left, and right.
axis
The axis attribute is not recognized by most browsers. This attribute is used to create a list of category names which form the basis of a query. This query is executed against the cells that form the table.
bgcolor
The bgcolor attribute is deprecated effective with version 4.0. You are now to use style sheets. This attribute is used to set the background color for the cell. It can be either a named color (such as red) or a six character hexadecimal RGB color code (such as #e26fa9). This value overrides any color value that was set in the table or tr tags.
char
The char attribute permits you to select a character that will be used to align the contents of the cell. This was designed to allow the decimal points in a column of numbers to be in vertical alignment. The default value is country dependent. In the U.S., it is the first occurrence of a period or a decimal point.
charoff
The charoff attribute is an integer used to specify if the value designated in the char attribute is to be the first, second, or whatever occurrence.
colspan
The colspan attribute allows a header to span horizontally two or more columns (cells). This may be combined with the rowspan attribute to form data cells that encompass several rows and columns.
headers
The headers attribute is not recognized by most browsers. The value of this attribute is a list of cell header names. The names are the values of the cells' id attributes. This attribute is used with speech capable browsers.
height
The height attribute is deprecated effective with version 4.0. You are now to use style sheets. You use this attribute to set a minimum height for the cell. This value is an integer number of pixels. However, you may exceed this minimum height to accommodate the cell contents. The tallest cell in the row determines the actual maximum height which will be adopted by all of the cells in that row.
nowrap
The nowrap attribute is deprecated effective with version 4.0. You are now to use style sheets. You use this attribute to stop word wrapping and display the cell contents in one continuous line. However, you can insert br and p tags to create line and paragraph breaks.
rowspan
The rowspan attribute allows a cell to extend down two or more rows. This may be combined with the colspan attribute to form data cells that encompass several rows and columns.
scope
The scope attribute is not recognized by most browsers. It is used to assign a set of data cells to one header cell. The four possible values are col, colgroup, row, and rowgroup.
valign
The valign attribute is used to set the vertical alignment of the cell contents. The possible values are baseline, bottom, middle, and top.
width
The width attribute is deprecated effective with version 4.0. You are now to use style sheets. It is used to set the horizontal width of the cell. This value is an integer number of pixels. The widest cell sets the width for the entire column.
TD tag
The th tag is used to create a header cell for the cells in a row in a table element.
The ending tag is optional. However, it is recommended that it be included.
The coding sequence is:
Core Attributes
class dir id lang onclick ondblclick onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup style title
Attributes
abbr
The abbr attribute is not recognized by most browsers. You use it to provide an abbreviated summary of the data cell text.
align
The align attribute is used to set the horizontal alignment of the cell contents. The possible values are center, char, justify, left, and right.
axis
The axis attribute is not recognized by most browsers. This attribute is used to create a list of category names which form the basis of a query. This query is executed against the cells that form the table.
bgcolor
The bgcolor attribute is deprecated effective with version 4.0. You are now to use style sheets. This attribute is used to set the background color for the cell. It can be either a named color (such as red) or a six character hexadecimal RGB color code (such as #e26fa9). This value overrides any color value that was set in the table or tr tags.
char
The char attribute permits you to select a character that will be used to align the contents of the cell. This was designed to allow the decimal points in a column of numbers to be in vertical alignment. The default value is country dependent. In the U.S., it is the first occurrence of a period or a decimal point.
charoff
The charoff attribute is an integer used to specify if the value designated in the char attribute is to be the first, second, or whatever occurrence.
colspan
The colspan attribute allows a header to span horizontally two or more columns (cells). This may be combined with the rowspan attribute to form data cells that encompass several rows and columns.
headers
The headers attribute is not recognized by most browsers. The value of this attribute is a list of cell names. The names are the values of the cells' id attributes. This attribute is used with speech capable browsers.
height
The height attribute is deprecated effective with version 4.0. You are now to use style sheets. You use this attribute to set a minimum height for the cell. This value is an integer number of pixels. However, you may exceed this minimum height to accommodate the cell contents. The tallest cell in the row determines the actual maximum height which will be adopted by all of the cells in that row.
nowrap
The nowrap attribute is deprecated effective with version 4.0. You are now to use style sheets. You use this attribute to stop word wrapping and display the cell contents in one continuous line. However, you can insert br and p tags to create line and paragraph breaks.
rowspan
The rowspan attribute allows a cell to extend down two or more rows. This may be combined with the colspan attribute to form data cells that encompass several rows and columns.
scope
The scope attribute is not recognized by most browsers. It is used to assign a set of data cells to one header cell. The four possible values are col, colgroup, row, and rowgroup.
valign
The valign attribute is used to set the vertical alignment of the cell contents. The possible values are baseline, bottom, middle, and top.
width
The width attribute is deprecated effective with version 4.0. You are now to use style sheets. It is used to set the horizontal width of the cell. This value is an integer number of pixels. The widest cell sets the width for the entire column.
Forms
The following pages provide a beginning tutorial in how to put forms on your web page, how to include scripts, and some other common forms concepts.
FORM tag
Browser compatibility: Explorer 4, 5 Netscape 4, 6
The form tag is used to delimit the start and stop of a form element and serves as a container for form controls (fields). Control is a technical term which refers to the various elements that can be used inside a form to gather information. The information gathered is referred to as the contents or parameters of the form and is a collection of name/value pairs.
The four tags that can be used to build a form are:
button, input, select, textarea,
The general concept is that the user fills out the appropriate sections of the form as a response to a request for information (such as a shipping address). The user then clicks the submit button. The contents of the form are then submitted for processing, usually to another page on the web site. However, you can also submit to the same page, or to a window or frame.
This ability to use a web site to display products and information, to gather a response via a form from a user, to store and manipulate the gathered information, and then to have the web site respond dynamically to the user input, is the heart of the e-commerce/e-business industry.
There are two required attributes for the form tag. The action attribute dictates where the form contents will be submitted. The method attribute specifies how to send the submission.
It is recommended that you should only place one form per page. It may prove best to divide a long form between two or more pages.
A form element should not contain other form tags. The closing tag is mandatory.
Core Attributes
class dir id lang onclick ondblclick onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup style title
Attributes
accept
The accept attribute is a comma-separated list of file types that can be accepted by the server when using the type="file" content.
accept-charset
The accept-charset attribute is a comma-separated or space-separated list of the character types that the server must be able to support (process) when the contents of a form are submitted.
action
The action attribute sets the URL of the page that the contents (name/value pairs) of the form will be submitted to for processing.
enctype
The enctype attribute specifies the MIME type used to encode the contents of a form. The default is application/x-www-form-urlencoded. When using type="file" content, this attribute must be set to multipart/form-data.
method
The method attribute specifies which of two permitted HTTP methods will be used to pass the contents of a form. The more commonly used post method submits the contents of the form in a two step procedure. First the URL specified by the action attribute is contacted. Second, if the contact is successful, the contents are transmitted to the URL. The get method appends the contents to the end of the URL specified by the action attribute. (A question mark is used to delimit the end of the URL and the start of the contents.)
name
The name attribute is a string of characters that is used to label a form control (field) with a name. The name must be unique to that document and cannot be reused.
onreset
The onreset attribute is an event that allows the execution of JavaScript code when the user resets (clears) the form.
onsubmit
The onsubmit attribute is an event that allows the execution of JavaScript code when the user submits the form. For example, you could call a JavaScript function that performs client-side form verification to ensure that the form is filled out correctly (see code example).
target
The target attribute is used to submit the contents of the form to a specified window or frame.
Here is a sample form that includes client-side verification of fields.