Online Software Educational Training - IT Tutorials - Online Education Training for Computer Software


Home

HTML




Most Web browsers can display inline images (that is, images next to text) that are in X Bitmap (XBM), GIF, or JPEG format. Other image formats are also being incorporated into Web browsers [e.g., the Portable Network Graphic (PNG) format]. Each image takes additional time to download and slows down the initial display of a document. Carefully select your images and the number of images in a document. 

To include an inline image, enter:-- 

<BODY BGCOLOR="#FFFFFF">
<IMG SRC="PENGUINE1.JPG" WIDTH=77 HEIGHT=84>
</BODY>
inline image

The syntax for <IMG SRC> URLs is identical to that used in an anchor HREF. If the image file is a GIF file, then the filename part of ImageName must end with .gif. Filenames of X Bitmap images must end with .xbm; JPEG image files must end with .jpg or .jpeg; and Portable Network Graphic files must end with .png. 

The source specify what image, it also specifys where is the image. The above source, "PENGUINE1.JPG", means that the browser will look for the image named PENGUINE1.JPG in the same folder (or directory) as the html document itself. Below are a few diagrams.

SRC="Penguine1.jpg" means that
the image is in the same folder as
the html document calling for it.
SRC="images/Penguine1.jpg" means
that the image is one folder down
from the html document that called
for it. This can go on down as many
layers as necessary.
SRC="../Penguine1.jpg" means that
the image is in one folder up from
the html document that called for it.
SRC="../../Penguine1.jpg" means that
the image is two folders up from the
html document that called for it.

 

As you can see, the browser figures out how big the image is all by itself. Why bother with dimensions then? Without getting into details, it makes your page load faster because it is easier for the browser.

<BODY BGCOLOR="#FFFFFF">
<IMG SRC="PENGUINE1.JPG" Width=200 Height=84>
</BODY>

width and height

 

<BODY BGCOLOR="#FFFFFF">
<IMG SRC="PENGUINE1.JPG" Width=30 Height=84>
</BODY>

width and height

You can specify whatever dimensions you want and override the proper dimensions.





You should include two other attributes on <IMG> tags to tell your browser the size of the images it is downloading with the text. The
HEIGHT and WIDTH attributes let your browser set aside the appropriate space (in pixels) for the images as it downloads the rest of the file. (You can get the pixel size from your image-processing software, such as Adobe Photoshop. Some browsers will also display the dimensions of an image file in the title bar if the image is viewed by itself without an enclosing HTML document.) 

For example, to include a self portrait image in a file along with the portrait's dimensions, enter:-- 

<IMG SRC=SelfPortrait.gif HEIGHT=100 WIDTH=65>

NOTE:-- Some browsers use the HEIGHT and WIDTH attributes to stretch or shrink an image to fit into the allotted space when the image does not exactly match the attribute numbers. Not all browser developers think stretching/shrinking is a good idea, so don't plan on your readers having access to this feature. Check your dimensions and use the correct ones. 






You have some flexibility when displaying images. You can have images separated from text and aligned to the left or right or centered. Or you can have an image aligned with text. Try several possibilities to see how your information looks best. 

Aligning Text with an Image:--


By default the bottom of an image is aligned with the following text, as shown in this paragraph. You can align images to the top or center of a paragraph using the ALIGN= attributes TOP and CENTER. 

This text is aligned with the top of the image (
<IMG SRC = "BarHotlist.gif" ALT="[HOTLIST]" ALIGN=TOP>). Notice how the browser aligns only one line and then jumps to the bottom of the image for the rest of the text. 

And this text is centered on the image (
<IMG SRC = "BarHotlist.gif" ALT="[HOTLIST]" ALIGN=CENTER>). Again, only one line of text is centered; the rest is below the image. 


Images without Text:-- 


To display an image without any associated text (e.g., your organization's logo), make it a separate paragraph. Use the paragraph ALIGN= attribute to center the image or adjust it to the right side of the window as shown below: 

<p ALIGN=CENTER>
<IMG SRC = "BarHotlist.gif" ALT="[HOTLIST]">
</p>







Some World Wide Web browsers -- primarily the text-only browsers such as Lynx -- cannot display images. Some users turn off image loading even if their software can display images (especially if they are using a modem or have a slow connection). HTML provides a mechanism to tell readers what they are missing on your pages if they can't load images. 

The ALT attribute lets you specify text to be displayed instead of an image. For example: 

<IMG SRC="UpArrow.gif" ALT="Up">

where UpArrow.gif is the picture of an upward pointing arrow. With graphics-capable viewers that have image-loading turned on, you see the up arrow graphic. With a text-only browser or if image-loading is turned off, the word Up is shown in your window in place of the image. 

You should try to include alternate text for each image you use in your document, which is a courtesy for your readers or, for users who might be visually impaired, a necessity. 





Inline images can be used as hyperlinks just like plain text. The following HTML code: 

<BODY BGCOLOR="#FFFFFF">
Go to <A HREF="http://msn.com"><IMG SRC="PENGUINE1.JPG" Width=77 Height=84></A>
</BODY>

Inline images can be used as hyperlinks just like plain text.
Send me

The blue border that surrounds the image indicates that it's a clickable hyperlink. You may not always want this border to be displayed, though. In this case you can use the BORDER attribute of the IMG tag to make the image appear as normal. Adding the BORDER attribute and setting it to zero: 

If you don't want blue border around the image when you make it a link. Then!!

The BORDER attribute can also be set to non-zero values, whether or not the image is used as a hyperlink. In this case, the border will appear using the default text color for the web page. For instance, if you wanted to give your image a plain black border to help it stand out on the page, you might try this: 

<BODY BGCOLOR="#FFFFFF">
Go to <A HREF="http://msn.com"><IMG SRC="PENGUINE1.JPG" Width=77 Height=84 BORDER=0></A>
</BODY>

nline images can be used as hyperlinks just like plain text.
Send me

 

When you include images on a page, remember that they contain a lot of data and therefore can be slow to load. One way to reduce the size is to reduce the dimensions. Cutting the length and width in half results in an image only 1/4 the size in Kb. Also you can reduce the number of colors. For example:

Dimensions
Dimensions
Dimensions - 300 x 185
# of colors - 128
Size - 21 K
Dimensions - 200 x 123
# of colors - 32
Size - 4 K

 





Newer versions of Web browsers can load an image and use it as a background when displaying a page. Some people like background images and some don't. In general, if you want to include a background, make sure your text can be read easily when displayed on top of the image. 

Background images can be a texture (linen finished paper, for example) or an image of an object (a logo possibly). You create the background image as you do any image. 

However you only have to create a small piece of the image. Using a feature called tiling, a browser takes the image and repeats it across and down to fill your browser window. In sum you generate one image, and the browser replicates it enough times to fill your window. This action is automatic when you use the background tag shown below. 

The tag to include a background image is included in the
<BODY> statement as an attribute: 

<BODY BACKGROUND="StainedGlass.jpg">
HTML Tutor Lesson 2
</BODY>

The tag to include a background image.
HTML Tutor Lesson 3






By default browsers display text in black on a gray background. However, you can change both elements if you want. Some HTML authors select a background color and coordinate it with a change in the color of the text. 

Always preview changes like this to make sure your pages are readable. (For example, many people find red text on a black background difficult to read!) In general, try to avoid using high-contrast images or images that use the color of your text anywhere within the graphic. 

You change the color of text, links, visited links, and active links (links that are currently being clicked on) using further attributes of the
<BODY> tag. For example: 

<BODY BGCOLOR="#000000" TEXT="#FFFFFF" LINK="#9690CC">

This creates a window with a black background (BGCOLOR), white text (TEXT), and silvery hyperlinks (LINK). 
The six-digit number and letter combinations represent colors by giving their RGB (red, green, blue) value. The six digits are actually three two-digit numbers in sequence, representing the amount of red, green, or blue as a hexadecimal value in the range 00-FF. For example, 000000 is black (no color at all), FF0000 is bright red, 0000FF is bright blue, and FFFFFF is white (fully saturated with all three colors). 

These number and letter combinations are generally rather cryptic. 


For some basic colors -- typically those in the standard sixteen-color Windows 3.1 palette -- you can also use the name of the color instead of the corresponding RGB value. For example, "black", "red", "blue", and "cyan" are all valid for use in place of RGB values. However, while not all browsers will understand all color names, any browser that can display colors will understand RGB values, so use them whenever possible. 

For Example:--

<html>
<head>
<title>
bpbonline.com - HTML Tutor
</title>
</head>
<body BGCOLOR="#ACC2FF">
HTML Tutor Lesson 3
</body>
</html>

 

HTML Tutor Lesson 3


'#0000ff' is computerese for blue. Additionally if a background color is specified that is not one of the listed colors, then browser will usually pick the closest of these colors to use.




You may want to have an image open as a separate document when a user activates a link on either a word or a smaller, inline version of the image included in your document. This is called an external image, and it is useful if you do not wish to slow down the loading of the main document with large inline images. 

To include a reference to an external image, enter:-- 

<A HREF="MyImage.gif">link anchor</A>

You can also use a smaller image as a link to a larger image. Enter:-- 


<A HREF="LargerImage.gif"><IMG SRC="SmallImage.gif"></A>

The reader sees the SmallImage.gif image and clicks on it to open the LargerImage.gif file. 
Use the same syntax for links to external animations and sounds. The only difference is the file extension of the linked file. For example, 

<A HREF="AdamsRib.mov">link anchor</A> 

specifies a link to a QuickTime movie. Some common file types and their extensions are: 


plain text 
.txt 
HTML document 
.html 
GIF image 
.gif 
TIFF image 
.tiff 
X Bitmap image 
.xbm 
JPEG image 
.jpg or .jpeg 
PostScript file 
.ps 
AIFF sound file 
.aiff 
AU sound file 
.au 
WAV sound file 
.wav 
QuickTime movie 
.mov 
MPEG movie 
.mpeg or .mpg 


Note:-
Keep in mind your intended audience and their access to software. Most UNIX workstations, for instance, cannot view QuickTime movies. 






Before HTML tags for tables were finalized, authors had to carefully format their tabular information within <PRE> tags, counting spaces and previewing their output. Tables are very useful for presentation of tabular information as well as a boon to creative HTML authors who use the table tags to present their regular Web pages. (Check out the NCSA home page for an excellent example of using tables to control page layout.) 

Think of your tabular information in light of the coding explained below. A table has heads where you explain what the columns/rows include, rows for information, cells for each item. In the following table, the first column contains the header information, each row explains an HTML table tag, and each cell contains a paired tag or an explanation of the tag's function. Table Elements

Element Description:-- 


<TABLE> ... </TABLE> defines a table in HTML. If the BORDER attribute is present, your browser displays the table with a border. 
<CAPTION> ... </CAPTION> defines the caption for the title of the table. The default position of the title is centered at the top of the table. The attribute ALIGN=BOTTOM can be used to position the caption below the table. 
NOTE: Any kind of markup tag can be used in the caption. 
<TR> ... </TR> specifies a table row within a table. You may define default attributes for the entire row: ALIGN (LEFT, CENTER, RIGHT) and/or VALIGN (TOP, MIDDLE, BOTTOM). See Table Attributes at the end of this table for more information. 
<TH> ... </TH> defines a table header cell. By default the text in this cell is bold and centered. Table header cells may contain other attributes to determine the characteristics of the cell and/or its contents. See Table Attributes at the end of this table for more information. 
<TD> ... </TD> defines a table data cell. By default the text in this cell is aligned left and centered vertically. Table data cells may contain other attributes to determine the characteristics of the cell and/or its contents. See Table Attributes at the end of this table for more information. 


Table Attributes:-- 


NOTE:-- Attributes defined within <TH> ... </TH> or <TD> ... </TD> cells override the default alignment set in a <TR> ... </TR>


Attribute Description :--


ALIGN (LEFT, CENTER, RIGHT) Horizontal alignment of a cell. 
VALIGN (TOP, MIDDLE, BOTTOM) Vertical alignment of a cell. 
COLSPAN=n The number (n) of columns a cell spans. 
ROWSPAN=n The number (n) of rows a cell spans. 
NOWRAP Turn off word wrapping within a cell. 





The general format of a table looks like this:-- 

<TABLE>
<!-- start of table definition -->

<CAPTION> caption contents </CAPTION> 
<!-- caption definition -->

<TR> 
<!-- start of header row definition -->
<TH> first header cell contents </TH> 
<TH> last header cell contents </TH> 
</TR> 
<!-- end of header row definition -->

<TR> 
<!-- start of first row definition -->
<TD> first row, first cell contents </TD>
<TD> first row, last cell contents </TD> 
</TR> 
<!-- end of first row definition -->

<TR> 
<!-- start of last row definition -->
<TD> last row, first cell contents </TD>
<TD> last row, last cell contents </TD> 
</TR> 
<!-- end of last row definition -->

</TABLE>
<!-- end of table definition -->


You can cut-and-paste the above code into your own HTML documents, adding new rows or cells as necessary. The above example looks like this when rendered in a browser. 

The
<TABLE> and </TABLE> tags must surround the entire table definition. The first item inside the table is the CAPTION, which is optional. Then you can have any number of rows defined by the <TR> and </TR> tags. Within a row you can have any number of cells defined by the <TD>...</TD> or <TH>...</TH> tags. Each row of a table is, essentially, formatted independently of the rows above and below it. This lets you easily display tables like the one above with a single cell, such as Table Attributes, spanning columns of the table. 






Some HTML authors use tables to present nontabular information. For example, because links can be included in table cells, some authors use a table with no borders to create "one" image from separate images. Browsers that can display tables properly show the various images seamlessly, making the created image seem like an image map (one image with hyperlinked quadrants). 

Using table borders with images can create an impressive display as well. Experiment and see what you like. 






Web forms let a reader return information to a Web server for some action. For example, suppose you collect names and email addresses so you can email some information to people who request it. For each person who enters his or her name and address, you need some information to be sent and the respondent's particulars added to a data base. 

This processing of incoming data is usually handled by a script or program written in Perl or another language that manipulates text, files, and information. If you cannot write a program or script for your incoming information, you need to find someone who can do this for you. 

The forms themselves are not hard to code. They follow the same constructs as other HTML tags. What could be difficult is the program or script that takes the information submitted in a form and processes it. Because of the need for specialized scripts to handle the incoming form information, fill-out forms are not discussed in this primer. Check the Additional Online Reference section for more information.