Home > Web Front-end > HTML Tutorial > How to import images in html

How to import images in html

coldplay.xixi
Release: 2023-01-03 09:26:14
Original
56672 people have browsed it

htmlHow to import images: First create a new html file, insert the img tag in the body tag; then add the "src" attribute to the tag, and fill in the path of the image you want to add as the attribute value; then add " alt" attribute; finally use "width" and "height" to control the width and height of the image.

How to import images in html

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

htmlHow to import images:

1. Create a new html file, as shown in the figure, insert the img tag in the body tag. It should be noted that img is in There is no closing 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 import images 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 import images 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 import images in html

Free learning recommendation: html video tutorial

The above is the detailed content of How to import images in html. 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