Img - Html tag for inserting a picture (Src), aligning and wrapping text around it (align), as well as setting the background (background)

Description

To insert graphic images into an HTML document, use the HTML tag (img abbreviation from English words image- image). Images are not inserted directly into the web page, the tag only contains a link to the image and creates the required size of space in which the image is displayed in graphic format GIF, JPEG or PNG:

  • JPG is the most common format for photographs. Images with the .jpg extension display millions of colors, which is especially important for accurately displaying the different tones and gradients in photos. However, such images cannot contain transparent areas.
  • GIF is used for simple graphics such as logos. GIF images are not used for photographs because they cannot contain as much color information as JPG images. However, GIF images can have transparent areas and can be compressed into very small file sizes. Also GIF format supports animation.
  • PNG is an image format that, like JPG, allows you to display millions of colors and contain transparent areas. However, as a rule, images with a .png extension have several larger size than JPG or GIF.

HTML tag has two required attributes: src and alt.

The src attribute plays an important role in displaying graphics on the page - it sets the path (relative or absolute) to the image, which is not technically inserted into the page: the browser displays the image to which the link leads.

The alt attribute specifies alternative text for the image, which will only be displayed when the image cannot be displayed (the path specified is incorrect or the image has been deleted).

If necessary, the image can be made a link; all you need to do is place a tag inside the element. In this case, a frame will appear around the image, which can be easily removed using CSS:

Images can also be used as image maps - this is where one image contains multiple hotspots different shapes, each of which is separate link. Such a map appearance no different from a regular image.

Note: To add images to a web page, you can also use the background-image CSS property, which allows the usual the background replace the element with an image.

Attributes

src: Tells the browser the location (URL) of the desired image. Example » alt: Provides text description

pictures, displayed on the screen only if the picture for some reason cannot be displayed. Note: to create a tooltip when you hover over an image, you need to use the global title attribute . The attribute value is an arbitrary string in which you can indicate Additional information

about the picture. Example » If a picture is used as a decoration for a web page and does not carry any semantic meaning, then instead of describing the picture, you can leave an empty line (alt="") as the value. height: Specifies the height of the image in pixels. ismap: The ismap attribute is a Boolean attribute. Its presence indicates to the browser that the picture is part of an image map located on the server (an image map is an image with interactive areas).

Valid values Boolean attribute ismap: When you click on the interactive area of ​​the image map, the click coordinates are sent to the server in the URL query string. Note: the ismap attribute is only used if the element is

child element tag containing the href attribute. Usemap: Defines an image as an image map. The value (must begin with the "#" character) specified in this attribute is associated with the value of the name or id attribute of the tag

and creates connections between elements And .