<img> tag in HTML is used to insert images into a web page. The
<img> tag is a self-closing tag, which means it does not require a closing tag. Here is an example of using the
src attribute is used to specify the URL of the image. The
alt attribute is used to provide alternative text for the image, which is important for accessibility as it can be read by screen readers. The
height attributes are used to specify the size of the image in pixels.
Here are some additional attributes that you can use to customize the image:
class: Assigns one or more class names to an element, which can be used to define the styles using CSS.
id: Assigns a unique id to an element, which can be used to define the styles using CSS or to create links to specific sections of a page.
style: Defines an inline style for an element, which can be used to define the styles using CSS directly within the HTML code.
title: Provides additional information about the image, which is displayed as a tooltip when the user hovers over the image.
You can also use CSS to style your images such as adding border, padding, margin, and more.
It’s important to use the
alt attribute correctly, as it makes your content more accessible to users, including those using assistive technology such as screen readers. Also, be sure that the images are optimized for web use, which can be done by resizing, compressing, etc.