Return to Homepage
Home : Web Site Images : Position Images

How To Position Images
When Added To A Webpage

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:

  • Align
  • Border
  • Hspace
  • Vspace
  • Alt
  • Height
  • Weight

HTML Src Diagram Showing Most Common Image Values


HTML Src

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.

Step 1: Copy Code Below and Paste into HTML Document

Step 2: Update Code To Display and Position Images

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:

  • Image Name--ends in .jpg or .gif or .png
  • Alt Tag--use a keyword-rich image description to help Search Engines find your site. I get a huge number of visitors because I faithfully use well defined alt tags.
  • Height and Width--I adjust these in Photoshop before I upload my images to the server. Then it's just a matter of updating these values to match Photoshop. Trying to adjust these in your HTML document instead of your photo editor is hard to do accurately as they have to be adjusted proportionately (if you update height by 25 px you must do the same to width. Even so, you may not get the desired effect).

    Learn how to size images here. Find detailed instructions with HTML code plus a video showing how to size images in Photoshop and Picnik.

Update these as needed to display and position images:

  • Align--use to position images left, right or center
  • Border--thickness is defined in pixels; 0 = no border. Color is usually defined by names, like red or gray (click here for a full list of browser-friendly color names. Type is usually solid or dotted.
  • Hspace--controls space around image. Always use to keep text from getting too close to your images. 10 or 15 should do it.
  • Vspace--use to position images vertically. I use when I have more text than the height of the image that I'm lining up next to it. See example here. In this example, I used an Hspace of 15 and a Vspace of 15.

How To Position Images in Specific Situations

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.




Latest Articles

Free Website Tutorials Top 5 Online Careers - Can You Guess?
Free Website Tutorials How To Wrap Text Around Images
Free Website Tutorials Learn to Create a Free Website Template
Free Website Tutorials Free Keyword Analyzer & Excel Macros
Free Website Tutorials How to Create a Web Page Shadow







[?] Subscribe To This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Subscribe with Bloglines


Follow SandeeLembke on Twitter



Browser View

Description

HTML Image Code

HTML SrcContent 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

ALIGN="left". Hspace and Vspace control space around image.

<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.
HTML SrcContent 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

ALIGN="right"

<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.

HTML Src

Content that my visitors want to read, read, read, read, read, read.

Image centered between two paragraphs

div align="center" and ALIGN in HTML src is set to "0" because div is controlling alignment.

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.

HTML Src

Image aligned to the right of 250 x 250 Google Ad Bank

Use the "Span" code to align the Ad then use ALIGN="right" plus Hspace and Vspace to position images away from ad and to center vertically.

<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.

Site Build It Review


Quick Jump Links, aka anchor links, help your visitors navigate a webpage especially if it is long.

Click here to see them on a real page
and here if you want to learn more about
how to build anchor links.


Image aligned to the right of link list

ALIGN="right" plus Hspace and Vspace used to move image closer to links and to center vertically.

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) 

SBI! Overview
SBI! Features
SBI! Forums
SBI! Cost
Worried About Time?
No Web Site Topic?
Not Technically Savvy?
Poor Writing Skills?
Money Back Guarantee
Super Affiliate Handbook
One SBIer's Success Story

<br clear="all">
<br clear="all">

Text Next To Image

Stack images on top of each other with text next to them

Images and text are perfectly aligned by use of tables. Copy the exact code in the 3rd column then update it for your own use.

Right click, select all, then copy and paste into your HTML document. Adjust code for your images (see Step 2 above).

Text Below Image

Line up images next to each other with text or links below them

Images and text are perfectly aligned by use of tables. Copy the exact code in the 3rd column then update it for your own use.

Right click, select all, then copy and paste into your HTML document. Adjust code for your images (see Step 2 above).







Free-Website-Tutorials.com--Copyright© 2009 - 2010