Free WebSchools.com

Google



Submit ArticleForumsLive chat WebhostingSEO ToolsLink TO UsResources


HOME

HTML Basic

HTML Introduction
HTML Basic Tags
HTML Formatting

HTML Entities
HTML Links
HTML Frames
HTML Tables



HTML Lists
HTML Forms
HTML Images

HTML Background
HTML Colors


HTML Advanced
HTML Fonts
HTML Styles
HTML Head
HTML Meta

HTML Scripts
HTML Events


The Image Tag and the Src Attribute



In HTML, images are defined with the <img>tag. To display an image on a page, you need to use the src attribute. Src stands for "source". The value of the src attribute is the URL of the image you want to display on your page.



The syntax of defining an image:
<img src="url"> The URL points to the location where the image is stored.

The Alt Attribute



The alt attribute is used to define an "alternate text" for an image. The value of the alt attribute is an author-defined text:
<img src="rose.gif" alt="red rose"> The "alt" attribute tells the reader what he or she is missing on a page if the browser can't load images. The browser will then display the alternate text instead of the image. It is a good practice to include the "alt" attribute for each image on a page, to improve the display and usefulness of your document for people who have text-only browsers.

Example

output

this is A background image!

gif and jpg files can be used as HTML backgrounds .

If the image is smaller than the page, the image will repeat .

notes

  • You can make a picture larger or smaller changing the values in the "height" and "width" attributes of the img tag.for example
    <img src="rose.gif" width="45" height="45">