如何去掉a标签的下划线

首先来了解下<a>标签的一些样式:

<a>标签的伪类样式

一组专门的预定义的类称为伪类,主要用来处理超链接的状态。超链接文字的状态可以通过伪类选择符+样式规则来控制。伪类选择符包括:
总: a 表示所有状态下的连接 如 a{color:red}
① a:link:未访问链接 ,如 a:link {color:blue}
② a:visited:已访问链接 ,如 a:visited{color:blue}
③ a:active:激活时(链接获得焦点时)链接的颜色 ,如 a:active{color:blue}
④ a:hover:鼠标移到链接上时 ,如 a:hover {color:blue}
一般a:hover和a:visited链接的状态(颜色、下划线等)应该是相同的。
前三者分别对应body元素的link、vlink、alink这三个属性。
四个“状态”的先后过程是:a:link ->a:hover ->a:active ->a:visited。另外,a:active不能设置有无下划线(总是有的)。

举例:伪类的常见状态值

  1. <style type = “text/css”>
  2. <!--
  3. a {font-size:16px}
  4. a:link {color: blue; text-decoration:none;} //未访问:蓝色、无下划线
  5. a:active:{color: red; } //激活:红色
  6. a:visited {color:purple;text-decoration:none;} //已访问:purple、无下划线
  7. a:hover {color: red; text-decoration:underline;} //鼠标移近:红色、下划线
  8. -->
  9. </style>
  1. <style type = “text/css”>   
  2. <!--   
  3. a {font-size:16px}   
  4. a:link {color: blue; text-decoration:none;} //未访问:蓝色、无下划线   
  5. a:active:{color: red; } //激活:红色   
  6. a:visited {color:purple;text-decoration:none;} //已访问:purple、无下划线   
  7. a:hover {color: red; text-decoration:underline;} //鼠标移近:红色、下划线   
  8. -->   
  9. </style>  


如何去掉<a>的下划线:
对超链接下划线设置 使用代码"text-decoration"
语法:
text-decoration : none || underline || blink || overline || line-through

text-decoration参数:
none :  无装饰
blink :  闪烁
underline :  下划线
line-through :  贯穿线
overline :  上划线

去掉下划线的方法就是将其text-decoration设置为none即可。
如:<style>a{text-decoration:none}</style>
可以在此基础上发挥:如:<style>.myclass a{text-decoration:none}</style>
<style>div a{text-decoration:none}</style>

可以扩展至<a>标签的伪类:
a:link{text-decoration:none; cursor:pointer; color:red;}
a:visited{text-decoration:overline; cursor:pointer}
a:active{text-decoration:overline; cursor:pointer}
a:hover{text-decoration:overline; cursor:pointer}
.myclass:hover{text-decoration:overline; cursor:pointer}


<a>标签的一些属性

a标签是成对出现的,以<a>开始, </a>结束
属性.
Common -- 一般属性
accesskey -- 代表一个链接的快捷键访问方式
charset -- 指定了链接到的页面所使用的编码方式,比如UTF-8
coords -- 使用图像地图的时候可以使用此属性定义链接的区域,通常是使用x,y坐标
href -- 代表一个链接源(就是链接到什么地方)
hreflang -- 指出了链接到的页面所使用的语言编码
rel -- 代表文档与链接到的内容(href所指的内容)的关系
rev -- 代表文档与链接到的内容(href所指的内容)的关系
shape -- 使用图像地图的时候可以使用shape指定链接区域
tabindex -- 代表使用"tab"键,遍历链接的顺序
target -- 用来指出哪个窗口或框架应该被此链接打开
title -- 代表链接的附加提示信息
type -- 代表链接的MIME类型

posted on 2016-09-20 15:37  何甘霖  阅读(4602)  评论(0编辑  收藏  举报