超链接(Hyperlink)是网页中用于从一个页面链接到另一个页面或同一页面的不同部分的元素。CSS(Cascading Style Sheets)是一种样式表语言,用于描述HTML或XML(包括SVG、XHTML等)文档的外观和格式。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Hyperlink Example</title>
<style>
/* 基础样式 */
a {
color: blue;
text-decoration: none;
}
/* 悬停效果 */
a:hover {
color: red;
text-decoration: underline;
}
/* 访问过的链接 */
a:visited {
color: purple;
}
/* 激活状态的链接 */
a:active {
color: green;
}
</style>
</head>
<body>
<h1>Hyperlink CSS Example</h1>
<p>Visit our <a href="https://example.com">website</a> for more information.</p>
<p>Learn more about <a href="#section1">Section 1</a> below.</p>
<h2 id="section1">Section 1</h2>
<p>This is section 1.</p>
</body>
</html>
a
、a:hover
、a:visited
、a:active
。href
属性正确设置。-webkit-
、-moz-
)来兼容不同浏览器。通过以上方法,你可以有效地管理和优化超链接的CSS样式,提升网页的用户体验和一致性。