ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

12-HTML Images

Images are defined with the  <img> tag in HTML. This  <img> tag is empty and does not have a closing tag, but it only contains attribute.

 

The src attribute is the one that specifies the URL (location) of an image

example:

<img src=”url” alt=”name here” />

 

The alt attribute is the one that specifies an alternate text for an image, if it cannot be displayed. It also provides alternative text if the src attribute has an error due to slow connection.

example:

name here

 

The style attribute is used to specify the width and height of an image.

 

<img src=”url” alt=”name here” style=”width:100px;height:100px;” />

 

 

or you can use this instead.

 

<img src=”url” alt=”name here” width=”100″ height=”100″ / >

 

To put a link into an image, simply place the tag inside the tag.
Example:

 

<a href=”http://itsourcecode.com/”>
<img src=”http://itsourcecode.com/wp-content/uploads/2015/10/cropped-ITSourceCodeLogo1-300×300.png” alt=”ITSourceCodeLogo.png” width=”300″ height=”300″ style=”width:100px;height:100px;” />
</a>

 

Result:


ITSourceCodeLogo.png

Facebook Comments

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!