Home > Web Front-end > Front-end Q&A > How to set underline in css

How to set underline in css

藏色散人
Release: 2023-01-05 16:07:50
Original
6265 people have browsed it

How to set underline in css: first create an HTML sample file; then define some text content in the body; finally add underline to the text through the "text-decoration:underline;" style.

How to set underline in css

The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.

css add underline:

There are two ways to add underline style to font text. One is to use the html underline tag directly, and the other is to use the CSS underline style. Let's take a look at how to add underlines using css.

css can use the text-decoration attribute to add underlines. Use the text-decoration:underline; style to underline text.

Example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title></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 effect is as follows:

How to set underline in css

text-decoration attribute description:

text-decoration attribute specification Modifications added to text.

Note: The modified color is set by the "color" attribute.

This attribute allows setting 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.

Attribute value:

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 defines blinking text.

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

【Recommended learning: css video tutorial

The above is the detailed content of How to set underline in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
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