Knowing some basics of HTML is always handy, especially when it’s as simple as adding an image to your blog post or web page. To define an image, all one needs to do is create an tag and apply the correct properties to it. How would you do that one might ask?
Knowing how to work with the tag will also help you become a better blogger. Not in writing mind you, but in form and style. It can also help you on other networks as well. Imagine you wanted to add an image to your MySpace profile, would you know how? What if you wanted to put an image in an area that most people only put text? Perhaps by including an
tag you could impress your friends by injecting an image where they were not able to, or didn’t think to.
Before we dig in, I want to point out that we first started with how to create a hyperlink and explained a little about it. Then we took that a step further and defined the title property of the hyperlink and what that will do for you. To round off the hyperlinks, I showed you how one might use the target property of the hyperlink to retain visitors on your site. I am building on the knowledge within those posts, so if you are finding yourself a bit lost, try reading through those posts. If all else fails, I’m always here to help you out.
Also, so I don’t confuse anyone, I wrote a post that also explains how to include an image in your Blogger posts. The methods I’ll describe here will take you to the nuts and bolts of adding an image by writing the HTML yourself. Sometimes writing it yourself is quicker, other times the automated interfaces we use will be easier. That is for you to decide.
Basic Structure of the Image Tag
The image tag is no different than any other tag, except for a few minor differences. Firstly, let’s take a look at the tag itself and examine what makes the tag tick.
<img src="http://www.waynejohn.com/images/someimage.jpg" alt="my alt text" height="20px" width="20px" title="the title" />
The first thing you might notice is that the whole tag is wrapped neatly. Don’t fear, that’s just me making what would be a REALLY long line of text look nicer for readability. Normally, you wouldn’t do this unless you were explaining it to a bunch of random strangers (and some not so random) like I am here.
The second thing you might notice is that there isn’t an ending tag. Remember with the hyperlink anchor tag we had both a starting and ending tag set, like this:
<a href="SomeUrl>blaha>
Instead, the tag is one of those self-closing tags I mentioned. You don’t need to have, in fact it is improper to have an ending as part of the structure. Instead, we end the tag with the self-closing />.
Also keep in mind that each of the properties (src, alt, height, width and title) are property value pairs. This means that each will follow the same conventions of:
PropertyName=”SomeValue”
With those basics covered, lets take a closer look at each of the property value pairs normally found in the tag.
Image Tag Properties
There really is only one property you need to include with each image tag, and that is the src property. Well, if you want to conform to web standards, you should also include the alt property as well (I’ll explain more about that soon). Some systems may barf when it’s not included, so keep that in mind.
The src Property
The src property stands for ’source’ as you might have already guessed. It points to where the image is on either your server, or on another domain. The src property tells the tag where the source image file is located, and when a browser reads this tag, it will reach out to grab the image based on what you provide as the value for the src property.
There are many ways to refer to a source image, too many to list here. In fact, that will be another post in itself. Subscribe now so you don’t miss it. (personal plug)
The alt Property
The alt property allows a browser to display the text contained in this property when the image cannot be displayed. Sometimes people surf without seeing any images either because they turned them off, or because they are using a text based browser that doesn’t interpret images (like the old OLD days). The alt text will display in place of the image in these cases.
According to W3C standards, each image tag should contain an alt property value pair, even if the value part is simply “” (an empty quote). This is for XHTML accessibility and validity purposes. If you want to know more about that, click here.
The title Property
The title property works just like our hyperlink title property. It will give the user a yellow tooltip when the user passes their mouse over the image. This is handy for including a little more about the image or perhaps adding additional instructions to users. There is also talk of Google and other search engines looking at the title property of the tag to gain more information about the page and image being scanned. Whether this is true or not, I don’t know. What I do know is that to be thorough, you might want to include a title property on certain images.
The Width and Height Property
The width and height properties are completely optional. If you choose to leave them out, the image will render in what I call it’s “normal viewing dimensions”. It’s like looking at an 8×5 photo and wishing you could make it a wallet size. The 8×5 photo is the images normal viewing dimension. To make the image wallet size, you would include the width and height property to size the image to the dimensions you would like.
When you do this, you might happen to ’skew’ the image. This happens when the ratio that you increase or decrease the image is disproportionate to the images normal viewing dimension. You’ll know when this happens when you look at your image and it looks like the end of a Bruce Lee film, where everyone is suddenly tall and lanky. On the other end of that spectrum is the short and squatty image.
Important to note! When you resize the dimensions of an image, it still retains all the bytes of it’s normal size. For example, you can’t take your huge desktop wall paper that may be 3 megabytes in size (much too large for display on the web) and make it the size of an Altoids tin and expect the number of bytes to drop. It will still load as slow as molasses, but it will be much smaller in dimension! To actually ‘resize’ an image can mean two things, dimension or byte size. I have only mentioned dimension size here, not byte size. That is also another post for another day.
Conclusion
Now it’s time for those of us adventurous types to play around with the image tag a bit to embed it in our brains. It’s handy to know these things and it will only serve to make you a better blogger or web designer.
Do you have any questions relating to the image tag or anything found in this post? Please feel free to ask by leaving a comment. I left many holes in this topic due to the elaboration one might have to go through to cover all the points. I plan to cover everything about this in due time. Until then, let me have it with any questions you might have.
Resources
W3C’s HTML Images Page
Alt Attributes: Describing Your Images for Better Web Accessibility
You might also enjoy these related posts
- Introduction to HTML Div Tags What is a div tag? Do you know? Most likely your blog is arranged and structured by using ‘div tags’. Divs are nothing more than boxes on a 2...
- Blogger.com Help – Lesson 6 – Adding an image to a post There is much more to blogging than just writing good posts, whatever you define good to be. You might also want the ability to create a stylish and compelling...
- The Differences Between HTML and Blogger Template Code Do you understand the difference between HTML and Blogger template code? When you take a look at a Blogger template, are you able to read it? I mean, do...
- Creating a Hyperlink Don’t know what one is or how to make one? This is the post for you then. This post is intended for those that really don’t understand what a...
- The Hyperlink Title Property Explained It doesn’t matter how long you’ve been blogging, there is always something to learn. In this post, we’ll take a further look at the simple hyperlink and how we...




Heff, if you’re going to post like that, you might want to dress things up a bit…just my two cents. hahahaha Make things more festive in the bar! LOL
Cyndi, ok, you are the second person that has brought that up, and the first time I became distracted and forgot to fix it. It’s working now. The problem was from trying to include a title attribute so that Stumble would automatically add the title of the post as the title of the Stumble. Apparently StumbleUpon keeps that attribute in the URL so that it fails when SU tries to add it into their database.
Long answer for Thanks, got it fixed! Thanks very much for the Stumble!
Hi! I tried to Stumble this but got an error message … might wanna check that out. I was able to stumble the home page, though.
Cyndi
Hey, does anyone know where I can find a fresh ear of corn, LMAO !!!
HAHAHAHA! Heff, you have done quite well for yourself then, especially if you did it with an axe in your lap and high as a kite. hahahaha
Indeed Adam. There are probably psychology tests done to see how long a persons attention remains on something technical/they’re interested in/Not interested in, etc…That would make a nice post I think.
yes, that might be a post in itself…the optimized post length.
I learned all my blogging tricks like a blind drunk trying to walk down a flight of stairs, but so far so good.
Excellent advice Adam, thanks for putting an SEO perspective on that. I tried to keep to the basics and then later posts I’ll expand upon this.
I actually use 5px for vert and 10px for horizontal. At least, that’s the standard I’ve found works for images in posts on this blog.
Methinks long technical posts scare people, less is more approach?
Great post Wayne. Just a few tips… be careful of keyword stuffing and it is suggested that the alt tag and title tag for each image be exactly the same.
How about vspace and hspace attributes? A designer friend told me to use vspace =”10″ and hspace=”10″ as well as border=”0″ to give a space around your pics.