Home  >  Article  >  Web Front-end  >  How to set the background color of css hyperlink

How to set the background color of css hyperlink

藏色散人
藏色散人Original
2020-12-24 09:28:123059browse

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>

The HTML code is as follows:

c60d0098e2af3bc4a416224b3165943fphp Chinese website5db79b134e9f6b82c0b36e0489ee08ed

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!

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