Home / code / html

Images in HTML.

There are 3 file-types that are used for pictures on the web:

  • GIF 8-bit colors
  • JPEG 24-bit colors
  • PNG

What does this mean ?
GIF is used when there aren't many different colors in the image. Like logo's.
JPEG is used for pictures and photos.
PNG is an updated version of GIF.

Now the code.
<IMG SRC="URL">

You can also use alternative.
<IMG SRC="URL" alt="text">

This is shown when the image is not shown or when the mouse stays above the image for a few seconds.
It is recommended that you use it.

If you want to align the image:
<IMG SRC="URL" ALIGN="TOP|BOTTOM|MIDDLE|LEFT|RIGHT">

You align the image compared to the text around it.
Bottom is standard.

Height and width:
<IMG SRC="URL" WIDTH="?" HEIGHT="?">

It is recommended that you always add the width and height.
The browser can then reserve space before the image is loaded.
Especially in pages with tables, your page loads much faster then.
You can find the width and height (pixels) of a image in every graphic program.

You can add a border around the image.
<IMG SRC="URL" BORDER="?">

You replace ? with thickness in pixels.

If you want more space between the image and the text around it.
<IMG SRC="URL" HSPACE="?" VSPACE="?">

Again replace the ? with the space in pixels.

 

TOP

Latest script:

 

Books: