tags:

views:

74

answers:

4

I had created one HTML page for my experiance. In this i had use the background image like c:\documents ans settings.....\leftline.png. But i don't know how to add images from a common directory. (like background-image= ('./images/leftline.png'). how i can do like this?

A: 

You have to save the images inside the directory of your website and then you can acess these images using relative path.

If your page for example Default.htm lies inside the virtual directory WebSite1 then you can create a folder for images say 'Images' and can point to an image inside the 'Images' directory by using 'Images/image1.jpg'

If from your html file you have to traverse a folder up then you can use '../Images/image1.jpg'

You can also give an absolute path for the image like http://.....

rahul
A: 

Put the files in a directory that is in the same folder the html file is in. name the folder images.

Colin
+5  A: 

The second line you have is a relative address, relative to the "thing" that is calling it.

So, say you have a webpage called "index.html" and it lives in C:\My Documents\WebPages\My Page. You might also have C:\My Documents\WebPages\My Page\images\leftline.png

Now, rather than type in "C:\My Documents\WebPages\My Page\images\leftline.png" we can simply use "images\leftline.png" in our index.html page. Why? Well, check the locations:

C:\My Documents\WebPages\My Page\images\leftline.png
C:\My Documents\WebPages\My Page\index.html

RELATIVE to index.html, leftline is only one directory away, so you can address relatively.

Oni
A: 

You need to have this image inside your website. And then the trick is to work out what URL to use (that's apparently your problem).

When you use an HTML image tag () in you page, then the browser sees the URL you specify. If that URL is relative (does not start with "http://" or a "/"), then it is sees as relative to the URL of the page. So usually you will need some "../" to go back to the root of the site and then back up again to the image.

A URL that is specified inside a .css file is relative to that css file.

If you use asp.net and want to specify the image-url in a server tag ( for instance), then you can use a "~" as first character to specify the "root of the site". This will work only if that URL is processed by the server as a property of some server control.

Hans Kesting