css文字下划线怎么设置

html-css012

css文字下划线怎么设置,第1张

用text-decoration设置

值  描述

none    默认。定义标准的文本。  

underline    定义文本下的一条线。  

overline    定义文本上的一条线。  

line-through    定义穿过文本下的一条线。  

blink    定义闪烁的文本。  

inherit    规定应该从父元素继承 text-decoration 属性的值。 

实例

设置 h1、h2、h3、h4 元素的文本修饰:

h1 {text-decoration:overline}

h2 {text-decoration:line-through}

h3 {text-decoration:underline}

h4 {text-decoration:blink}

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

text-decoration: underline

示例如下:

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

<h2>我不加下划线</h2>

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

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

h2{color:blue} /*设置文字颜色为蓝色*/

h2.underline{text-decoration: underline} /*只为有underline标识的元素添加下划线*/

效果如下