Through ALOT of trial and error, I finally figured out how to position images correctly in all of the most important situations. Now I share the exact code with you.
First let's talk about what makes up a standard html src image call (src stands for source). In order to properly display an image on your webpage you need to use the following syntax:
<img src="url" />
The URL points to the location where the image is stored. In the diagram below, the image called "drop-shadow.jpg" is stored in a directory called "images" on "www.free-website-tutorials.com."
In addition to simply displaying them, you will most likely want to position images and add other features like an alt tag and possibly a border. In order to do that you need to add values to the html src code.
The image values (red in the diagram below) that you will use most often when you add and position images are:
The image tag you see in the diagram is the code that I used to display the diagram itself. The only thing I changed is that I aligned center.
I have gotten in the habit of using this exact code each time I want to add and position images changing it as needed. Sometimes I use all the html src image values and other times I just leave them set to "0" so that if I need them, they are there. I suggest you do the same.
After you copy and paste the above code into your HTML document where you want the image displayed, it is time to update the code. More than likely you will only have to update the server and directory (http://www.free-website-tutorials.com/images) the first time you use this code.
For the other values, ALWAYS update:
Update these as needed to display and position images:
The basic image HTML code above will definitely display an image on your webpage, but what if you have a special image positioning situation like wanting to line up your image next to a Google ad?
The situations listed below are ones that I struggled with when I first got started. I am sure there is more than one way to accomplish these things, but I have found code that works for me to position images and I'm sticking with it.
Feel free to copy and paste the code from the 3rd column and then update it for your own images.
Browser View |
Description |
HTML Image Code |
Content that my visitors want to read, content that my visitors want to read, content that my visitors want to read, content that my visitors want to read, read, read.
|
Image aligned to the left of the text
|
<img src="http://www.free-website-tutorials.com/images/water-lillies.jpg" ALIGN="left" style="border: 0px gray solid;" HSPACE="10" VSPACE="5" ALT="Water Lillies" HEIGHT="75" WIDTH="100"/>Content that my visitors want to read, content that my visitors want to read, content that my visitors want to read, read, read. |
Content that my visitors want to read, content that my visitors want to read, content that my visitors want to read, content that my visitors want to read, read, read.
|
Image aligned to the right of the text
|
<img src="http://www.free-website-tutorials.com/images/water-lillies.jpg" ALIGN="right" style="border: 0px gray solid;" HSPACE="10" VSPACE="5" ALT="Water Lillies" HEIGHT="75" WIDTH="100"/>Content that my visitors want to read, content that my visitors want to read, content that my visitors want to read, read, read. |
|
Content that my visitors want to read, read, read, read, read, read. ![]() Content that my visitors want to read, read, read, read, read, read. |
Image centered between two paragraphs
|
Content that my visitors want to read, read, read, read, read, read. <div align="center"img src="http://www.free-website-tutorials.com/images/water-lillies.jpg" ALIGN="0" style="border: 0px gray solid;" HSPACE="10" VSPACE="5" ALT="Water Lillies" HEIGHT="75" WIDTH="100"/> </div> Content that my visitors want to read, read, read, read, read, read. |
|
Image aligned to the right of 250 x 250 Google Ad Bank
|
<span style="text-align:left; float:left; width:250px; margin:5px;"/>
Google Code Goes Here </span> <img src="http://www.theme-party-queen.com/images/buffet3.jpg"
ALIGN="right" HSPACE="5" VSPACE="35" alt="Theme Party Queen Buffet" height="157" width="125" />
Maximum size of image is dependent on the width of your content area. |
Quick Jump Links, aka anchor links, help your visitors navigate a webpage especially if it is long. |
Image aligned to the right of link list
Maximum size of image is dependent on the width of your content area and the length of your links. |
<img src="http://www.theme-party-queen.com/site-build-it.jpg"
ALIGN="right" style="border: 0px gray solid;"
HSPACE="10" VSPACE="5" alt="Site Build It Review" height="250" width="250" />
Quick Jump Links (not real links)
<br clear="all"> <br clear="all"> |
|
Stack images on top of each other with text next to them
|
Right click, select all, then copy and paste into your HTML document. Adjust code for your images (see Step 2 above). |
|
Line up images next to each other with text or links below them
|
Right click, select all, then copy and paste into your HTML document. Adjust code for your images (see Step 2 above). |