The HTML image tag is

(*-*)浩
Release: 2019-09-10 08:53:52
Original
3200 people have browsed it

Image tag () and source attribute (Src)

The HTML image tag is

## In HTML, images are defined by the tag.

Images can be displayed in a document by using the tag.

is an empty tag, which means that it only contains attributes and has no closing tag. (Recommended learning:

HTML Getting Started Tutorial)

To display images on the page, you need to use the source attribute (src). src refers to "source". The value of the source attribute is the URL address of the image.

The syntax for defining an image is:

<img src="url" />
Copy after login

URL refers to the location where the image is stored. If an image named "boat.gif" is located in the images directory of www.w3school.com.cn, its URL is //m.sbmmt.com/images/boat.gif.

The browser displays the image in the document where the image tag appears. If you place an image tag between two paragraphs, the browser will display the first paragraph first, then the image, and finally the second paragraph.

Replacement text attribute (Alt)

The alt attribute is used to define a string of prepared replaceable text for the image. The value of the replacement text attribute is user-defined.

<img src="boat.gif" alt="Big Boat">
Copy after login

When the browser cannot load the image, the replacement text attribute tells readers the information they lost. At this point, the browser will display this alternative text instead of the image. It's a good practice to add the alt text attribute to all images on the page. This helps display information better and is very useful for those who use text-only browsers.

Basic Notes - Helpful Tips:

If an HTML file contains ten images, then in order to display the page correctly, 11 files need to be loaded. Loading images takes time, so our advice is: use images with caution.

The above is the detailed content of The HTML image tag is. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template