Home Web Front-end HTML Tutorial Use of html img tag

Use of html img tag

Dec 02, 2017 am 10:26 AM
html use Label

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">
Copy after login

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"/>
Copy after login

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">
Copy after login

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>
Copy after login

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>
Copy after login

where page1.html is Another html document, the code is as follows:

<html>
<head>
    <title>page1界面</title>
</head>
<body>
    <p>我是page1</p>
</body>
</html>
Copy after login


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>
Copy after login

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

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

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

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

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

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.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

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

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

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

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

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

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

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

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

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

See all articles