HTML Image Code

Adding images to your web page is quite simple and you will use it over and over again in your web development projects. There are a few different ways to do this, here is an example of one way:

<img border=”0″ src=”images/image.jpg” alt=”Image Text” width=”300″ height=”200″ />

You can see from this code, we have set the border to 0 pixels, this means there will be no “outline” on the image.
The src is the image source and that is where the image is located on your server or on the web. For example, if on the root directory of your web server you have an images folder, the link would read src=”images/image.jpg”. You can also use a full url such as src=”sitemilk.com/images/image.jpg”.
The alt is what displays when the image cannot be displayed. It is also helpful to the search engines to recognize what your image is about so be sure to be descriptive.
You can also specify the width and height dimensions here, its default value is pixels.

You can achieve the same effect with the code below using style tags, to me this is a little easier to code but it’s just personal preference.

<img style=”border: 0px; width: 300px; height: 200px;” src=”images/image.jpg” alt=”Image Text” />

I hope this simple image code helped someone, until next time,

Sitemilk

Leave a Comment

You must be logged in to post a comment