I'm learning html and having a lot of trouble understanding the use of the src attribute to load an image from local storage, such as the images directory on my hard drive or, when the webpage is uploaded to my webhost, the images directory of my webhost. Can someone please refer me to a summary of the basic information on that? Or, if I should use an attribute other than src, please let me know that as well.

Recommended Answers

All 6 Replies

Dear "Proglearner", Frist of all here's a link to the best HTML web tutorial:
(IMAGE TAG)
http://www.w3schools.com/html/html_images.asp

After reading this I think you will be able to more understand what is the src and how to use it.
I'll try to explain it in my own words:
<img src="images/test.jpg">
This is how we display an image in an html page.
<img> => image
src => source

THe src attribute will take the .html file directory as the main/default directory.
For example here src="images/test.jpg"
This means that in the same directory where the HTML file is located, there is a directory named 'images' which contain the file 'test.jpg'

Hope this was helpful, Good Luck ;)

Hi, Amir,

Thank you so much! What you told me worked perfectly.

I like w3schools but find that they cram a lot of information into a small space. I need to learn more slowly and am doing so.

Something else you can help me with: what is the css style attribute value for centering an image? I know that text is "text-align: center" but not sure about images.

Progz

There are a few techniques you can use to center an image. Text-align would work, but i generally use the technique of styling the image as a block element then applying a left and right margin to auto. Here is an example. In your stylesheet...

img.center {display: block; margin: 0 auto;}

The your image element apply a class="center". For example...

<img src="#" class="center" />

Please tell me about the advantages and disadvantages of using an inline stylesheet for a single webpage. I figure it's a lot simpler than a separate css file.

Actually, the use of an external style sheet is recommended when you have multiple web pages. This allows you to make a change in one file when you want to update multiple elements. If you use an internal or worse yet, inline styles, your managment of styles dramatically increases.

Thanks, guys. Solved. :) You're beautiful!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.