Current location - Quotes Website - Personality signature - 03.Image tag img
03.Image tag img

In HTML tags, the tag is used to define images in an HTML page.

src is a required attribute of the tag, which is used to specify the path and file name of the image file.

The so-called attributes: simply understood are the characteristics of this image tag.

Note:

1. The image tag can have multiple attributes, each of which must be written after the tag name.

2. The attributes are in no particular order, and the tag name and attributes, and attributes and attributes are separated by spaces.

3. The attributes take the format of key-value pairs, that is, the format of key="value" and attribute="attribute value".

4. You only need to set one of the width and height attributes of the image, and the other will scale proportionally. Setting both at the same time will cause image compression distortion.

Advantages:

1. The running environment is simple and clear, and does not change with changes in the location of the web page.

2. Relatively safe.

Disadvantages:

1. When the HTML is opened on another computer, or the drive letter of the image is changed, the image cannot be displayed on the page, and the portability of the image is poor. .

Right-click on the website to copy the image address and write it into src to successfully import it.

Advantages:

1. The path is simple and clear, making it easy to search with search engines.

2. As long as there is a network, no matter how the html file is moved, the picture can still be displayed normally.

Disadvantages:

It is not easy to transplant. If the website domain name changes, all images will become invalid.

The directory path is created based on the location of the html file. That is, the position of the image relative to the HTML page.

Just write directly, and be sure to add the suffix of the picture.