Cover Image for HTML Image
197 views

HTML Image

HTML Image is a tag used to display images on a webpage. The <img> tag is used to define an image in HTML.

Here’s an example of how to use image tags in HTML:

<img src="image.jpg" alt="Image" />

In this example, we’ve used an <img> tag to display an image called “image.jpg” on the webpage. The “src” attribute specifies the URL of the image file, and the “alt” attribute provides alternative text for the image, which is displayed if the image cannot be loaded or if the user is using a screen reader.

We can also add other attributes to the <img> tag to control the size and alignment of the image, such as “height”, “width”, and “align”. For example:

<img src="image.jpg" alt="Image" height="200" width="300" align="left" />

In this example, we’ve added the attributes “height” and “width” to set the dimensions of the image, and “align” to align the image to the left of the text.

Overall, HTML image tags are an important part of HTML formatting, as they allow us to display visual content on a webpage, making it more engaging and informative for users.


1. 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 image may be on the same directory or another server.


2. alt

The alt attribute defines an alternate text for the image, if it can’t be displayed. The value of the alt attribute describe the image in words. The alt attribute is considered good for SEO prospective.


3. width

It is an optional attribute which is used to specify the width to display the image. It is not recommended now. You should apply CSS in place of width attribute.


4. height

It h3 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.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS