Home>Article>Web Front-end> How to set underline in html
htmlHow to set underline: 1. Add underline to text through "text-decoration" attribute; 2. Set box underline through "border-bottom"; 3. Simulate underline through "linear-gradient()" .
The operating environment of this article: Windows 7 system, HTML5 version, Dell G3 computer.
Several implementation schemes of underline in css
When writing styles for text or a certain layout box, in order to make it look better or more conspicuous, it may be used Underline, record several implementation options here.
Text underline
It is actually relatively simple to add underline to text
text-decoration attribute
This attribute allows you to set certain effects, such as underlining. If the descendant element does not have its own decorations, the decorations set on the ancestor element will "extend" to the descendant elements. User agents are not required to support blink.
To put it simply, this attribute can set decorative effects for text, such as strikethrough, underline, etc.
The most commonly used one is to remove the default underline style of the a tag.
Example:
这是标题 1
这是标题 2
这是标题 3
这是标题 4
Example 1
(The color of text modification can be set through color)
BoxUnderline
border-bottom
border-bottom abbreviation property sets all bottom border properties in a declaration.
The properties that can be set are (in order): border-bottom-width, border-bottom-style, and border-bottom-color.
border-bottom By setting the lower border of the box , can play the role of simulating underlines
Example:
border-bottom: 1px solid #dbdbdb; border-top:0px; border-left:0px; border-right:0px;
Example 2
linear-gradient()
The linear-gradient() function is used to create an "image" of a linear gradient.
In order to create a linear gradient, you need to set a starting point and a direction (specified as an angle) of the gradient effect. You also need to define the end color. The stop color is the smooth transition you want Gecko to make, and you must specify at least two, although you can specify more colors to create more complex gradient effects.
This css function is not very common. Its function is to create a picture.
Use gradient function to simulate underline
. In fact, you set the background image, and then set the width and height to make it look like an underline.
Example:
菜鸟教程(runoob.com) 内容
Example 3
The underline created by this method is the most customizable.
You can draw nice underlines and even define animations~
[Recommended learning:html video tutorial】
The above is the detailed content of How to set underline in html. For more information, please follow other related articles on the PHP Chinese website!