Home >Web Front-end >HTML Tutorial >Detailed explanation of basic html image knowledge
This article mainly shares with you a detailed explanation of basic html image knowledge. HTML images - image tags (a1f02c36ba31691bcfe87b2722de723b) and source attributes (Src). In HTML, images are defined by the a1f02c36ba31691bcfe87b2722de723b tag. a1f02c36ba31691bcfe87b2722de723b is an empty tag, which means that it only contains attributes and no closing tag.
To display an image 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 images is:
<img src="url" alt="some_text">
URL refers to the location where the image is stored. If the image named "pulpit.jpg" is located in the images directory of www.runoob.com, then its URL is https://img.php.cn/upload/article/000/054/025/69ee4cbf3049b8bcc16a7e91b3657b16-0.jpg .
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.
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">
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.
The height (height) and width (width) attributes are used to set the height and width of the image.
The default unit of attribute value is pixels:
<img src="pulpit.jpg" alt="Pulpit rock" width="304" height="228">
Tip: It is a good habit to specify the height and width of the image. If an image has a specified height and width, the specified dimensions will be retained when the page loads. If the size of the image is not specified, the overall layout of the HTML page may be destroyed when the page is loaded.
Note: 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.
Note: When loading the page, pay attention to the path to insert the page image. If the position of the image cannot be set correctly, the browser cannot load the image, and the image tag will display a broken image.
Tag | Description |
---|---|
Define image map | |
Define clickable areas in image maps |
The above is the detailed content of Detailed explanation of basic html image knowledge. For more information, please follow other related articles on the PHP Chinese website!