怎样用CSS样式在文字下面加下划线

怎样加下划线///是怎样一个步骤

一般有两种方法:

一、通过CSS下划线代码:text-decoration:underline来设置文字下划线。

实例演示如下:

1、实例代码如下:

此时页面效果如下:

2、修改第1步中的txt样式,加入text-decoration:underline。

此时页面效果如下,出现了下划线。

二、通过设置div的border实现效果:

实例演示如下:

在第一种方法的初始代码上,增加border-bottom: 1px solid black、padding-bottom: 10px两个关键样式,如下:

此时页面效果如下:

温馨提示:内容为网友见解,仅供参考
第1个回答  2015-05-26

给需要添加下划线的元素应用如下css样式即可

text-decoration: underline;

示例如下:

    给需要添加下划线的元素一个标记,这里设置为一个名叫underline的类

    <h2>我不加下划线</h2>
    <h2 class="underline">我要加下划线</h2>

    应用上面给出的添加下划线的样式

    h2{color:blue;}  /*设置文字颜色为蓝色*/
    h2.underline{text-decoration: underline;}  /*只为有underline标识的元素添加下划线*/

    效果如下

第2个回答  2013-06-06
默认时就会加的!
也可以加如下代码:
<style type="text/css">
<!--
a:link {text-decoration: underline;}
a:visited {text-decoration: underline;}
a:active {text-decoration: underline;}
a:hover {text-decoration: underline;}
-->
</style>本回答被网友采纳
相似回答