html images dr. baker abdalahq. the image tag and the src attribute in html, images are defined with...

6
HTML Images HTML Images Dr. Baker Abdalahq Dr. Baker Abdalahq

Upload: gilbert-phelps

Post on 20-Jan-2016

215 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: HTML Images Dr. Baker Abdalahq. The Image Tag and the Src Attribute In HTML, images are defined with the tag. In HTML, images are defined with the tag

HTML ImagesHTML Images

Dr. Baker AbdalahqDr. Baker Abdalahq

Page 2: HTML Images Dr. Baker Abdalahq. The Image Tag and the Src Attribute In HTML, images are defined with the tag. In HTML, images are defined with the tag

The Image Tag and the Src The Image Tag and the Src Attribute Attribute

In HTML, images are defined with In HTML, images are defined with the <img> tag.  the <img> tag. 

The <img> tag is empty, which The <img> tag is empty, which means that it contains attributes only means that it contains attributes only and it has no closing tag. and it has no closing tag.

To display an image on a page, you To display an image on a page, you need to use the src attribute. Src need to use the src attribute. Src stands for "source". The value of the stands for "source". The value of the src attribute is the URL of the image src attribute is the URL of the image you want to display on your page. you want to display on your page.

Page 3: HTML Images Dr. Baker Abdalahq. The Image Tag and the Src Attribute In HTML, images are defined with the tag. In HTML, images are defined with the tag

The syntax of defining an image:The syntax of defining an image: <img src="url"> The URL points to the <img src="url"> The URL points to the

location where the image is stored. An location where the image is stored. An image named "boat.gif" located in the image named "boat.gif" located in the directory "images" on directory "images" on "www.w3schools.com" has the URL: "www.w3schools.com" has the URL: http://www.w3schools.com/images/boat.gif. http://www.w3schools.com/images/boat.gif.

The browser puts the image where the The browser puts the image where the image tag occurs in the document. If you image tag occurs in the document. If you put an image tag between two paragraphs, put an image tag between two paragraphs, the browser shows the first paragraph, then the browser shows the first paragraph, then the image, and then the second paragraph. the image, and then the second paragraph.

Page 4: HTML Images Dr. Baker Abdalahq. The Image Tag and the Src Attribute In HTML, images are defined with the tag. In HTML, images are defined with the tag

The Alt Attribute The Alt Attribute

The alt attribute is used to The alt attribute is used to define an "alternate text" for an define an "alternate text" for an image. The value of the alt image. The value of the alt attribute is an author-defined attribute is an author-defined text: text:

Page 5: HTML Images Dr. Baker Abdalahq. The Image Tag and the Src Attribute In HTML, images are defined with the tag. In HTML, images are defined with the tag

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

Page 6: HTML Images Dr. Baker Abdalahq. The Image Tag and the Src Attribute In HTML, images are defined with the tag. In HTML, images are defined with the tag

Basic Notes - Useful TipsBasic Notes - Useful Tips

If an HTML file contains ten If an HTML file contains ten images - eleven files are images - eleven files are required to display the page required to display the page right. Loading images take time, right. Loading images take time, so my best advice is: Use so my best advice is: Use images carefully. images carefully.