Use of html img tag
This article explains in detail the various functions of the picture tag in html. Pictures are definitely indispensable in a html page, The img tag of html is also very simple and easy to master. Let’s take a look!
img displays this map uses a relative path such as:
<img src="./imgs/002.jpg">
Development tips: In actual development, it will generally be in the project directory Create an imgs folder and put all the image resources in it to facilitate image calling during development. As shown above, ./imgs is the directory where the image is found, and /002.jpg is the image to be selected.
img displays web page images using absolute paths, such as:
<img src="https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png"/>
There are many attributes to choose from under img:
1. alt indicates the display content when the image is loaded incorrectly, so that visitors can know the purpose of the image.
For example:
<img src="./imgs/001.jpg12" alt="logo">
The displayed result is:
means that this picture is a logo picture.
2. align indicates the position where the image is aligned in the text.
top is aligned at the top, bottom is aligned at the bottom, and middle is aligned in the middle. Defaults to bottom alignment.
Two suspension effects: the left image floats to the left of the text, and the right image floats to the right of the text.
3. Change the size of the picture through width and height
The code demonstration of 2 and 3 is as follows
<p>一张百度logo<img src="./imgs/001.jpg" width="100"/></p> <p>一张百度logo<img src="./imgs/001.jpg" align="top" width="100"/></p> <p>一张logo<img src="./imgs/002.jpg" align="bottom" width="100"></p> <p>百度logo<img src="./imgs/002.jpg" align="middle" width="100"></p> <p>百度logo<img src="./imgs/002.jpg" align="left" width="100"></p> <p>百度logo<img src="./imgs/002.jpg" align="right" width="100"></p>
The pictures are all under relative paths Local picture
4. Click the picture to open another link
<p>点击图片打开链接 <a href="page1.html" title="点击进入page1界面"> <img src="./imgs/001.jpg" alt="logo" width="200px" align="middle"/></a></p>
where page1.html is Another html document, the code is as follows:
<html> <head> <title>page1界面</title> </head> <body> <p>我是page1</p> </body> </html>
Clicking on the image will open page1.html.
5. Image mapping
<img src="page.jpg" border="0" usemap="#page" alt="pages" /> <map name="page" id="page"> <area shape="circle" coords="180,139,14" href ="page1.html" alt="page1" /> <area shape="circle" coords="129,161,10" href ="page2.html" alt="page2" /> </map>
area and map are used together, and area is under the map tag. The usemap of img points to the name of the map. Click on different positions of the picture to enter two different links, page1 or page2.
The above is all about the use of html img tags. I hope it will be helpful to everyone.
Related recommendations:
Detailed graphic explanation of the difference between alt and title in the img attribute
#html in the tag detailed explanation on creating image mapping
Why not use the img tag to control the image size in html?
The above is the detailed content of Use of html img tag. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
