Home >Web Front-end >CSS Tutorial >How to set the background color of css hyperlink
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.
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!