Home > Article > Web Front-end > How to set underline in css
How to set underline in css: first create an HTML sample file; then define some text content in the body; finally add underline to the text through the "text-decoration:underline;" style.
The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.
css add underline:
There are two ways to add underline style to font text. One is to use the html underline tag directly, and the other is to use the CSS underline style. Let's take a look at how to add underlines using css.
css can use the text-decoration attribute to add underlines. Use the text-decoration:underline; style to underline text.
Example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style> h1 {text-decoration:overline;} h2 {text-decoration:line-through;} h3 {text-decoration:underline;} </style> </head> <body> <h1>This is heading 1</h1> <h2>This is heading 2</h2> <h3>This is heading 3</h3> </body> </html>
The effect is as follows:
text-decoration attribute description:
text-decoration attribute specification Modifications added to text.
Note: The modified color is set by the "color" attribute.
This attribute allows setting certain effects on text, 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.
Attribute value:
none Default. Text that defines the standard.
underline Defines a line under the text.
overline defines a line on the text.
line-through defines a line that passes under the text.
blink defines blinking text.
inherit specifies that the value of the text-decoration attribute should be inherited from the parent element.
【Recommended learning: css video tutorial】
The above is the detailed content of How to set underline in css. For more information, please follow other related articles on the PHP Chinese website!