Home >Web Front-end >Front-end Q&A >How to set the background of the link being visited with css

How to set the background of the link being visited with css

青灯夜游
青灯夜游Original
2021-09-10 16:11:321779browse

In css, you can use the ":active" selector and background attribute to set the background of the link you are visiting. You only need to add "a:active{background:color value/url('picture url'" to the link );}" style can set the background color or background image of the link when it is being accessed.

How to set the background of the link being visited with css

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

cssSet the background of the link being visited

When the mouse clicks on the link, set its background color to yellow.

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<style type="text/css">
			a:active {
				background: yellow;
				/* background:url(img/1.jpg); */
			}
		</style>
	</head>
	<html>
		<body>
			<a href="#">链接</a>
		</body>
	</html>

Rendering:

How to set the background of the link being visited with css

Description:

:active selector can set the style when you click the link.

When you click a link it becomes the active link, and :active adds special styling to active links.

Tips: :link selector sets the link style of unvisited pages, :visited selector sets the style of visited page links, :hover selector is used when the mouse is hovering over it link style.

Note: In order to produce the desired effect, in the CSS definition, :active must be located after :hover! !

Recommended tutorial: "CSS Video Tutorial"

The above is the detailed content of How to set the background of the link being visited with css. 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