Home  >  Article  >  Web Front-end  >  What are the attributes of the html img tag? Detailed explanation of image tag img

What are the attributes of the html img tag? Detailed explanation of image tag img

云罗郡主
云罗郡主Original
2018-11-12 11:55:4818931browse

Nowadays, any web page is inseparable from pictures. If a website is a web page that combines pictures and text, it will be loved by many users. If the website wants to get more traffic, it cannot do without pictures, so then Let’s take a look at the image tag img and summarize for you what are the attributes of the html img tag?

1: Introduction to image tag img

Generally, in html, we can use What are the attributes of the html img tag? Detailed explanation of image tag img to set the image. The img tag is There is no end tag for self-closing tags. We only need to master the three attributes of What are the attributes of the html img tag? Detailed explanation of image tag img and src, alt and title. [Recommended reading: Detailed explanation of img tag and changing image size in html (picture)]

1.src attribute is the file address of the image

2. The alt attribute is the text that appears when the picture is broken

3. The title attribute is the text displayed when the mouse is placed on the picture

Among the above three attributes, src and alt It is indispensable. Let’s explain these three attributes in detail below.

2: Detailed explanation of image tag img

1. The src attribute is an indispensable attribute for pictures. , generally the address source of the image, the syntax is:

<img  src="图片地址属性"/ alt="What are the attributes of the html img tag? Detailed explanation of image tag img" >

2. The alt attribute in the img tag

alt attribute is actually also for search engines to see, the syntax is:

<img src="图片地址" alt="图片描述(给搜索引擎看) ">

3.title attribute

The title attribute is the title of the image displayed when the mouse is moved over the image, allowing users to see the information about the image. Syntax: Picture description (for search engines)

For example:

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>图像标签img</title>
</head>
<body>
    <img src="https://img.php.cn/upload/article/000/000/003/5b49b0e610f26951.jpg" alt="php中文网" title="php中文网"/>
</body>
</html>

Display effect in the browser:

What are the attributes of the html img tag? Detailed explanation of image tag img

What are the attributes of the html img tag? A complete introduction to the detailed explanation of the image tag img. If you want to know more about Html5 tutorial, please pay attention to the php Chinese website.


The above is the detailed content of What are the attributes of the html img tag? Detailed explanation of image tag img. 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