HTML Image
HTML Image
The HTML img tag is used to display an image on the web page. The HTML img tag is an empty tag that contains attributes only, closing tags are not used in the HTML image element.

Example of HTML image.
<h2>HTML Image Example</h2>
<img src="http://www.easytolearning.com/images/logo.png" alt="Easytolearning Logo"/>
Output:
Html Image Example

The src and alt are important attributes of the HTML img tag. All attributes of the HTML image tag are given below.
src
It is a necessary attribute that describes the source or path of the image. It instructs the browser where to look for the image on the server.
The location of the image may be on the same directory or another server.
alt
The alt attribute defines an alternate text for the image if it can't be displayed. The value of the alt attribute describes the image in words. The alt attribute is considered good for the SEO perspective.
width
It is an optional attribute that is used to specify the width to display the image. It is not recommended now. You should apply CSS in place of width attribute.
height
It specifies the height of the image. The HTML height attribute also supports iframe, image and object elements. It is not recommended now. You should apply CSS in place of height attribute.
Supporting Browsers
| Element | Chrome | IE | Firefox | Opera | Safari |
| <h1> to <h6> | Yes | Yes | Yes | Yes | Yes |
HTML Images Tag Uses
- Use the HTML <img> element to define an image
- Use the HTML src attribute to define the URL of the image
- Use the HTML alt attribute to define an alternate text for an image, if it cannot be displayed
- Use the HTML width and height attributes to define the size of the image
- Use the CSS width and height properties to define the size of the image (alternatively)
- Use the CSS float property to let the image float
- Use the HTML <map> element to define an image-map
- Use the HTML <area> element to define the clickable areas in the image-map
- Use the HTML <img>'s element use map attribute to point to an image-map
- Use the HTML <picture> element to show different images for different devices
HTML Image Tags
| Tag | Description |
|---|---|
| <img> | Defines an image |
| <map> | Defines an image-map |
| <area> | Defines a clickable area inside an image-map |
| <picture> | Defines a container for multiple image resources |
