Home > Web Front-end > CSS Tutorial > How can I change the color of a strikethrough line in HTML?

How can I change the color of a strikethrough line in HTML?

Susan Sarandon
Release: 2024-11-19 13:20:02
Original
729 people have browsed it

How can I change the color of a strikethrough line in HTML?

Coloring Strikethrough Lines Differently from Text

The , , and HTML elements can all produce a striking effect on text. However, the strikethrough line often shares the same color as the text.

Using CSS to Change Strikethrough Color

Fortunately, CSS can be utilized to alter the color of the strikethrough line. Here's how:

  1. Wrap the Text in an Extra Element: Create an additional wrapping element to separate the strikethrough color from the text color.
  2. Assign the Strikethrough Color to the Outer Element: Set the desired strikethrough color to the outer element using the text-decoration property.
  3. Assign the Text Color to the Inner Element: Within the outer element, place an inner element and assign the desired text color to it.

Example

Consider the following code:

<span>
Copy after login

This code will display "black with red strikethrough" with the text in black and the strikethrough line in red. The outer <span> element sets the strikethrough color, while the inner <span> element sets the text color.

The above is the detailed content of How can I change the color of a strikethrough line in HTML?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template