You can use the text-decoration attribute in css to add an underline effect. You only need to set the "text-decoration:underline" style to the element. text-decoration specifies the decoration added to the text, and the value underline defines a line under the text.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
In CSS, you can use the text-decoration attribute to add an underline effect. The text-decoration attribute can specify the decoration added to the text. When the value is set to underline, it can define a line under the text, that is, the underline effect.
Let’s take a look at the code example:
<!DOCTYPE html> <html> <head> <style type="text/css"> p { text-decoration: underline } </style> </head> <body> <p>测试文本!</p> </body> </html>
Rendering:
Description:
The text-decoration attribute allows you to set 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.
Possible values:
Value | Description |
---|---|
default. Text that defines the standard. | |
Define a line under the text. | |
Define a line on the text. | |
Define a line that passes under the text. | |
Define blinking text. | |
Specifies that the value of the text-decoration attribute should be inherited from the parent element. |
css video tutorial)
The above is the detailed content of How to add underline in css. For more information, please follow other related articles on the PHP Chinese website!