How to insert html pictures

藏色散人
Release: 2023-01-05 16:12:12
Original
16354 people have browsed it

In HTML, pictures can be inserted through the tag. The inserted code is such as "<img src="dinosaur.jpg">", where the src attribute contains a pointer to the picture we want to introduce. The path can be a relative path or an absolute URL.

How to insert html pictures

The operating environment of this article: windows7 system, HTML5&&CSS3 version, DELL G3 computer.

We can use the element to put images on the web page. It is an empty element (it does not need to contain text content or a closing tag) and requires at least one src (usually read as its full name, source) to make it effective. The src attribute contains the path to the image we want to include, which can be a relative path or an absolute URL, just like the href attribute of the element.

Note: Before continuing, you should read the Quick Start URLs and Paths to review relative and absolute URLs.

For example, if you have an image named dinosaur.jpg, and it is stored in the same path as your HTML page, then you can embed it like this:

<img src="dinosaur.jpg">
Copy after login

If this picture is stored in the images folder with the same path as the HTML page (this is also recommended by Google, which is beneficial to SEO/indexing), then you can use the following form:

<img src="images/dinosaur.jpg">
Copy after login

and so on.

Note: Search engines also read the filenames of images and count them towards SEO. Therefore you should give your image a descriptive filename: dinosaur.jpg is better than img835.png.

You can also use absolute paths like the following:

<img src="https://www.example.com/images/dinosaur.jpg">
Copy after login

But this method is not recommended. Doing so will only make the browser do more work, such as re-passing DNS Then look for the IP address. Usually we put images and HTML on the same server.

[Recommended learning: HTML video tutorial]

The above is the detailed content of How to insert html pictures. 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