Can the src attribute of img be written in css?

WBOY
Release: 2022-06-30 14:42:27
Original
3350 people have browsed it

The src attribute of img can be written in css; the src attribute is used to set the url of the image file in the img tag, that is, the file path of the image. You can use the content attribute of css to specify the image url of the img tag. , you can achieve the purpose of using css to set the src attribute of the img tag. The syntax is "img{content:url(image file path);}".

Can the src attribute of img be written in css?

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

The src attribute of img can be written in css

Can the src attribute of img be written in css? The src attribute of the tag is required. Its value is the URL of the image file, which is the absolute or relative path to the file that references the image.

Tip: In order to organize the storage of documents, creators usually store image files in a separate folder, and usually name these directories something like "pics" or "images". In the W3School online tutorial, our engineers store most of the commonly used images in a folder named "i". "i" is the abbreviation of "images". The advantage of this is that it can simplify the path to the greatest extent. .

Syntax

<img  src="value" alt="Can the src attribute of img be written in css?" >
Copy after login

URL

Specifies the URL of the image.

Possible values:

Absolute URL - points to another site (such as src="http://www.example.com/")

Relative URL - points to the site The

content attribute is used with the :before and :after pseudo-elements to insert content.

The possible attribute values ​​​​of this attribute are as follows:

Can the src attribute of img be written in css?

The example is as follows:

<style>
    img {
    content:url(https://image.png);
    }
</style>
Copy after login

(Learning video sharing: css video tutorialhtml video tutorial)

The above is the detailed content of Can the src attribute of img be written in css?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
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