Blog-Support

Inserting images using HTML

posted Thursday, 1 February 2007

The web wouldn't be half the experience if it wasn't for the <IMG> tag. The <IMG> tag delivers the ability to easily insert images into a page from anywhere on the web. We'll take a look at this tag and the sort of things you can do with it

<IMG> basics

The <IMG> tag specifies not only the image location, but also how to present it on the page. The SRC attribute describes the location of the image as a URL or a URI. You can link an image in from anywhere on the web. For example:

<IMG SRC="http://www.google.com/images/logo.gif">

You can control the size of the image by specifying the WIDTH="" and HEIGHT="" attributes. You can specify the number of pixels, or percentage of original image, the size the image is to be resized to. It is not recommended that you let the browser size your image, as it will never make as good a job as a dedicated image program. In addition, you may be asking the user to download more bytes than they need to, if you aren't going to be displaying the full image.

In addition you can specify how the image positions itself to other elements beside. We can control this using the ALIGN="" attribute. This allows us to control how text is to flow around the image. Consider the two examples below. The first image has the ALIGN="LEFT" while the second has ALIGN="RIGHT".

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

There are a number of different values you can have in the ALIGN attribute and they include: LEFT, RIGHT, MIDDLE, TOP, BOTTOM. There are extra ones, but they do not operate on all browsers.

Being practical with images

One of the key things to remember when designing your pages with images inside them is how the page is physically built and rendered for the user. The HTML page is downloaded first, which is then interpreted by the browser and rendered. Then, if there are any images or external resources to retrieve, the download of them begin after the page has been rendered. Therefore it is possible for the user to see no images to begin with, and for them to then pop on the screen. But even that is on the assumption the resource was found.

So with that in mind, there are a number of techniques we can do to give the user a greater experience when viewing images.

Let us first look at the situation where the image is not found. Let us look at displaying the Google image, but assume for some reason it isn't available. We see this in the page:


<IMG SRC="badimage.jpg">

As you can see, the small generic invalid [x] box is displayed (some browsers may just display an empty space). As we can see from the ALIGN example at the top the size of the image can dramatically effect the page layout, which you may wish to maintain even if there is no image available. We would do this by specifying the width and height attributes. For example:


<IMG SRC="badimage.jpg" WIDTH="200" HEIGHT="100">

As you can see the size of the image has now been rendered. However, its still just an empty box. We can suggest alternative content should the image not be loaded yet, or is unavailable. We do this using the ALT attribute. For example:

Google Image
<IMG SRC="badimage.jpg" WIDTH="200" HEIGHT="100" ALT="Google Image">

Now you can see, the box has some text inside, which is great feedback for the user. But there is still more we can do. Just as we illustrated with the <A> tag, we can specify a TITLE attribute that will popup a small piece of text when the mouse hovers over it.

Google Image
<IMG SRC="badimage.jpg" WIDTH="200" HEIGHT="100" ALT="Google Image" TITLE="Google">

This allows you to add a little more depth to your images and increase the multimedia experience.

Linking From Images

As stated earlier you can make your links clickable by simply wrapping them in the <A> tag. For example:

<A HREF="http://www.google.com"><IMG SRC="http://www.google.com/images/logo.gif"></A>

Now if you click on the image, you will be taken to Google. However, do you notice something about the appearance of the image? It has a border around it. This is the default behaviour for images that are clickable. Sometimes this is not the look you are after and would prefer it not to be like that. You can turn off the border, by adding the attribute BORDER="0" to the <IMG> tag.

<A HREF="http://www.google.com"><IMG SRC="http://www.google.com/images/logo.gif" BORDER="0"></A>

tags:            



Need One-to-One Help?
If you are in any doubt, contact support

Related Posts

Tag Basics

More about HTML tags including anchors and special characters

First HTML Page

Beginners HTML

Inserting mp3s or music files.

Ever thought of inserting your favorite song as an mp3 or other audio file in to your blog? Here are the instructions on how to do so.

Site Header Images

If you want to customize your header for your blog, rather than use one of our predesigns. Here are some guidelines that may help you. if you want your header to suit both fixed and fluid layouts, make it 1600 pixels wide by 160 pixels high

How to add a Flash animation

Instructions on how to add a Flash animation to a blog entry, header, or custom portlet.

Inserting HTML/javascript code to your gutter

Instructions on how to add HTML or Javascript code to your blog's gutter. This can be used for adding AdSense, blog-rings, PayPal Donation buttons, weather pixies, images etc.

How do I put HTML into my blog entry?

If you are using the advanced editor, then you need to make sure you are in HTML mode before you add in HTML, do this by clicking the "html" button along the top.

Inserting images using HTML

Instructions and examples on how to insert an image using HTML. This can be used in the Basic Editor, widgets, headers, and any other fields where you can input HTML.

Paragraphs and Line breaks in HTML

How to work with paragraphs and linebreaks in HTML.

HTML Color Reference

Hex Color codes explained.

Images: GIF format

General information about the GIF image compression mechanism, the way it works, its suggested uses, special characteristics that differentiate it from other image compression mechanisms such as JPEG, and a comparison between their suggested usages.

Images: JPEG format

General information about the JPEG image compression mechanism, the way it works, its suggested uses, special characteristics that differentiate it from other image compression mechanisms such as GIF, and a comparison between their suggested usages.

How do I upload files to my blog?

Instructions on how to upload files to your blog's file space.

Basic HTML

Although you can use the advanced editor some people prefer to go with the basic one. This can be tricky if you don't know much HTML. Well here we will tell you some basic HTML you can use. From making a word bold to adding images.

FTP access to your files and photos

Instructions on how to access your blog's filespace using FTP.