How to set the background color of css hyperlink

藏色散人
Release: 2023-01-04 09:37:54
Original
3097 people have browsed it

How to set the background color of css hyperlink: first create an HTML sample file; then add the css style attribute to the hyperlink as "a:link {color:#FF0000;}a:visited {color:# 00FF00;}" to set the background color.

How to set the background color of css hyperlink

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

Recommended: "css Video Tutorial"

There are many CSS properties that can set link styles (such as color, font-family, background, etc.). The special thing about links is the ability to style them based on the state they are in.

There are 4 unique attributes of the a tag in CSS:

1.a:link (after adding the style, it means: the style when a certain hyperlink is not visited)

2 .a:visited (After adding the style, it means: the style of the hyperlink that refreshes the interface after being visited)

3.a:hover (After adding the style, it means: the style of the hyperlink when the mouse hovers)

4.a:active (after adding the style, it means: the style of the hyperlink at the moment the mouse clicks)

We can use these 4 attributes to set the background color of the hyperlink. It should be noted that these four expressions may not be written in full when describing, but the order must not be reversed.

The css style is as follows:

<style>
a:link {color:#FF0000;}/* 未被访问的链接 */
a:visited {color:#00FF00;}/* 已被访问的链接 */
a:hover {color:#FF00FF;}/* 鼠标指针移动到链接上 */
a:active {color:#0000FF;}/* 正在被点击的链接 */
</style>
Copy after login

The HTML code is as follows:

php Chinese website

The above is the detailed content of How to set the background color of css hyperlink. 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