HTML文字下划线怎么设置?很简单,用一个css样式就可以了。下面来看一下。
先在html里创建一段文字。
这时我们运行页面,可以看到这段文字并没有下划线的。
要添加下划线,我们添加一段css代码就行了,代码如下 text-decoration: underline。
再次运行页面,可以看到现在的文字就已经有了下划线了。
如何给HTML标签中的文本设置修饰线
text-decoration属性介绍#
text-decoration属性值说明表#
值作用none去掉文本修饰线underline设置下划线overline设置上划线line-through设置删除线
HTML标签自带修饰线#
u标签#
Copy<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>设置文本修饰线</title> </head><body> <u>成功不是击败别人,而是改变自己</u></body></html>
Copy<h1><u>成功不是击败别人,而是改变自己</u></h1>
s标签#
Copy<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>设置文本修饰线</title> </head><body> <s>成功不是击败别人,而是改变自己</s></body></html>
none去除修饰线#
Copy<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>设置文本修饰线</title> <style> s{ text-decoration: none; } </style></head><body> <s>成功不是击败别人,而是改变自己</s></body></html>
underline设置下划线#
Copy<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>设置文本修饰线</title> <style> h2{ text-decoration: underline; } </style></head><body> <h2>成功不是击败别人,而是改变自己</h2></body></html>
overline设置上划线#
Copy<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>设置文本修饰线</title> <style> h2{ text-decoration: overline; } </style></head><body> <h2>成功不是击败别人,而是改变自己</h2></body></html>
line-through设置删除线#
Copy<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>设置文本修饰线</title> <style> h2{ text-decoration: line-through; } </style></head><body> <h2>成功不是击败别人,而是改变自己</h2></body></html>