How to add underline in css

王林
Release: 2021-06-22 16:13:37
Original
3310 people have browsed it

The way to add underline in css is to set the text-decoration attribute to the text and set the attribute value to underline, such as [h3 {text-decoration:underline;}].

How to add underline in css

The operating environment of this article: windows10 system, css 3, thinkpad t480 computer.

To add underline, overline, strikethrough, etc. to a piece of text, you only need to add the text-decoration attribute to the text. Let's briefly introduce the text-decoration attribute.

The text-decoration attribute specifies the decorations added to the text, such as underline, overline, strikethrough, etc.

Commonly used attribute values ​​are as follows:

  • 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 Define blinking text.

  • #inherit Specifies that the value of the text-decoration attribute should be inherited from the parent element.

Code example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文网(php.cn)</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>
Copy after login

The running result is as shown below:

How to add underline in css

Related recommendations: 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!

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template