Home  >  Article  >  Web Front-end  >  How to add image path in html

How to add image path in html

coldplay.xixi
coldplay.xixiOriginal
2021-01-25 13:50:5012741browse

How to add an image path in html: First create a new html file and insert the img tag in the body tag; then add the "alt" attribute to the img tag; finally, the width and height of the image inserted in the img tag default to the image itself. width and height.

How to add image path in html

The operating environment of this tutorial: windows10 system, html5 version, DELL G3 computer. This method is suitable for all brands of computers.

Related learning recommendations: html tutorial

htmlHow to add image path:

1. Create a new html file, such as As shown in the figure, insert the img tag into the body tag. It should be noted that img does not have an end tag in html, so there is no need to add "". Add the "src" attribute to the tag, and fill in the attribute value with the path to the image you want to add. Here we take 1.png in the same directory as html as an example, so that the image is inserted:

How to add image path in html

2. In order to prevent users from being unable to load images when browsing the web, you can add the "alt" attribute to the img tag. This attribute can be displayed when the image fails to load to tell the user what image is here. It can also be used when the user When the mouse is placed on the picture, the prompt information is displayed. Here, the attribute value "parrot" is taken as an example:

How to add image path in html

3. The width and height of the picture inserted in the img tag default to the picture itself. The width and height. If you want to customize the width and height, you can use "width" and "height" to control it. Here, take the width and height as both 200 as an example. Set the attribute values ​​​​for "width" and "height" to " 200”:

How to add image path in html

The above is the detailed content of How to add image path in html. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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