Introduction to HTML : Adding images

Adding images

As the saying goes , "a picture is worth a thousand words". 

Images are embedded in HTML pages to illustrate concepts in a more concise and interesting manner. To put an image in a webpage, an <img> element is required. An <img> tag requires a src attribute which indicates the path of the image to be embedded in the page. The src attribute may be a file system path or a uniform resource locator (URL).

Example:

<img src="https://teachsomebody.com/TS_blue.png" >

Output:

 

undefined

Note that an <img> element has no end tag and content. 

The alt attribute

The alt attribute is a description of the image. This description is displayed when the image cannot be rendered.

<img src="https://teachsomebody.com/TS_blue.png" alt="This image is the logo of teachsomebody.com" >

In case the logo cannot be displayed, the alt text is displayed in place of the image.

The width and height attributes

The size of the image can be specified via the width and height attributes.

Example:

<img src="https://teachsomebody.com/TS_blue.png" width="40%" height="40%" > 

 

undefined

 


course logo
Introduction to HTML
Number of sections:
11
Content length:
Delivery formats: