CSS CSS Tutorial CSS Advanced CSS Responsive Web Design(RWD) CSS Grid CSS Properties Sass Tutorial Sass Functions



text-decoration-line

CSS (Cascading Style Sheets) is a style sheet language used for describing the presentation of a document written in HTML (Hypertext Markup Language). CSS provides a wide range of properties to style the text and other elements of a web page. One such property is text-decoration-line, which is used to specify the type of line to be used for text decoration.

Brief Explanation of Text-Decoration-Line

The text-decoration-line property is used to specify the type of line to be used for text decoration. Text decoration is used to add visual effects to the text, such as underlining, overlining, striking through, etc. The text-decoration-line property can take one of the following values:

  • none: No line is used for text decoration.
  • underline: A line is drawn under the text.
  • overline: A line is drawn over the text.
  • line-through: A line is drawn through the text.
  • underline overline: Both underline and overline are used for text decoration.
  • underline line-through: Both underline and line-through are used for text decoration.
  • overline line-through: Both overline and line-through are used for text decoration.
  • underline overline line-through: All three lines are used for text decoration.

The text-decoration-line property can be used with the text-decoration-color and text-decoration-style properties to further customize the text decoration.

Code Examples

Let's take a look at some code examples to understand how the text-decoration-line property works:

Example 1: Underline

The following code adds an underline to the text:

  <p style="text-decoration-line: underline;">This text is underlined.</p>

Output:

This text is underlined.

Example 2: Overline

The following code adds an overline to the text:

  <p style="text-decoration-line: overline;">This text is overlined.</p>

Output:

This text is overlined.

Example 3: Line-through

The following code adds a line through the text:

  <p style="text-decoration-line: line-through;">This text has a line through it.</p>

Output:

This text has a line through it.

Example 4: Multiple Lines

The following code adds both underline and overline to the text:

  <p style="text-decoration-line: underline overline;">This text has both underline and overline.</p>

Output:

This text has both underline and overline.

Example 5: Custom Color and Style

The following code adds a custom color and style to the text decoration:

  <p style="text-decoration-line: underline; text-decoration-color: red; text-decoration-style: dotted;">This text has a red dotted underline.</p>

Output:

This text has a red dotted underline.

References

Activity