Home > Article > Web Front-end > What does css strikethrough code mean?
The css strikethrough code is "text element {text-decoration:line-through;}". The css text-decoration attribute is used to specify modifications added to text, such as underline, overline, strikethrough, etc.; when the value of this attribute is set to "line-through", a line through the text can be defined, that is, Strikethrough effect.
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 achieve the strikethrough effect. The implementation code is:
文本元素{text-decoration:line-through;}
The text-decoration attribute specifies the modifications added to the text, underline, overline, Strikethrough etc.
Value | Description |
---|---|
none | Default. Text that defines the standard. |
underline | Define a line under the text. |
overline | Define a line on the text. |
line-through | Define a line that passes under the text. |
blink | Define blinking text. |
Description:
This attribute allows you to set a certain effect on the text, such as adding strikethrough. 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.
Code example:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>css添加文本文字的删除线</title> <style> p{ text-decoration:line-through; } </style> </head> <body> <p>这里有一条删除线</p> </body> </html>
As can be seen from the example, by setting text-decoration:line-through;
is the p element The text in the text is struck through, the method is simple and convenient. And you can simply modify the strikethrough style through css settings, such as: color, for example:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>css添加文本文字的删除线</title> <style> p{ text-decoration:line-through; color: red; } span{ color: black; } </style> </head> <body> <p><span>这里有一条删除线</span></p> </body> </html>
In this way, we combine text-decoration: line-through
and <span></span>
Style defines the style of text font color, and you can achieve the style effect of different colors of strikethrough and text in CSS. Isn’t it very simple!
(Learning video sharing: Getting started with web front-end)
The above is the detailed content of What does css strikethrough code mean?. For more information, please follow other related articles on the PHP Chinese website!