Adding Images to your Website

Tag Protocol

The following is how a basic image tag looks in HTML:

<img src="roses.jpg" />
<img> is the HTML element
src="images/photo.jpg" specifies the location of an image file to be included in the display of the Web page
The <img /> tag is an "empty" element - it has no closing sibling tag.

If the image can't be displayed, it's good to have an alt (alternative):
<img src="roses.jpg" alt="Large Bouquet of Red Roses" />

You can tell the browser, up front, the size of an image in your page ... but it's not required:
<img src="roses.jpg" alt="Large Bouquet of Red Roses" width="100" height="50" />

You can add a class to the <img />tag as well:
<img src="roses.jpg" alt="Large Bouquet of Red Roses" class="alignLeft" />

Types

photo of toddler

JPEG

The .jpg (or .jpeg) format works best for photos and complex graphics

funky logo

GIF

The .gif format works best for images with solid colors, logos, and geometric shapes.

photo of toddler

PNG

Portable Network Graphics (PNG) is a bitmapped image format that employs lossless data compression. PNG was created to improve upon and replace the GIF format, as an image-file format not requiring a patent license. PNG is pronounced "ping"

PNG vs GIF

PNG vs JPEG