How to display pictures in html

青灯夜游
Release: 2021-10-11 15:52:17
Original
32493 people have browsed it

How to display images in html: 1. Use the img tag with the syntax "How to display pictures in html"; 2. Add "background-image:url(image file) to the specified element Address);" style.

How to display pictures in html

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

htmlMethods for displaying pictures

Method 1: Use the img tag to insert pictures

In In HTML, you can use the img element to embed an image into a web page.

Please note that technically the How to display pictures in html tag does not insert an image into the web page, but rather links the image from the web page. The How to display pictures in html tag creates a placeholder for the referenced image.

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
	</head>
	<body>
		<img  src="img/1.jpg"    style="max-width:90%" / alt="How to display pictures in html" >
	</body>
</html>
Copy after login

How to display pictures in html

Method 2: Use css background-image attribute

Just add "background-image:url( Picture file address);" style

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<style>
			div{
				width: 500px;
				height: 300px;
				background-image: url(img/1.jpg);
				background-repeat: no-repeat;
				background-size: 400px;
			}
		</style>
	</head>
	<body>
		<div></div>
	</body>
</html>
Copy after login

Effect picture:

How to display pictures in html

## Recommended tutorial: "

html video tutorial

The above is the detailed content of How to display pictures in html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!