Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How does HTML insert a picture?


May 29, 2021 Article blog



When developing web pages, we can't help but insert pictures to enhance the user experience. So how do I insert a picture in HTML?

In HTML, the image is defined using <img> tag. T here are two required properties: src and alt The src property is used to determine the address of the picture, and the property of alt is used to determine the image's replaceable text.

Let's start with the specific code:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>插入图片 - 编程狮(w3cschool.cn)</title>
</head>
<body>
	<img src="./image/logo.png" alt="这是一张logo">
        <img src="https://7n.w3cschool.cn/statics/img/logo/[email protected]" alt="这是一张logo">
</body>
</html>

The first src is the relative address of the picture, and the second src is the image URL.

The end result:

 How does HTML insert a picture?1

That's how HTML inserts all the contents of a picture.