Home  >  Article  >  Web Front-end  >  How to set the font of elements and links to remain unchanged in css

How to set the font of elements and links to remain unchanged in css

WBOY
WBOYOriginal
2021-12-09 16:17:372303browse

Method: 1. Use the "text-decoration" attribute to remove the underline style of the link text. The syntax is "link element {text-decoration:none}"; 2. Use the color attribute to set the font color of the link text to black. That’s it, the syntax is “link element {color:#000}”.

How to set the font of elements and links to remain unchanged in css

The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.

How to set the font of elements and links in css to remain unchanged

In css, after adding a link to text, the font style will change. An example is as follows:

How to set the font of elements and links to remain unchanged in css

#If you want to set the font to remain unchanged after adding a link, you need to use the text-decoration attribute and the color attribute. The text-decoration attribute is suitable for removing the link style. Underline, the color attribute is used to set the font color to the original black.

The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
  a{
    text-decoration:none;
    color:#000;
  }
  </style>
</head>
<body>
添加链接的文字:<a href="https://www.php.cn/course/list/12.html" target="_blank">css视频教程</a>
<br>
没有添加链接的文字:css视频教程
</body>
</html>

Output result:

How to set the font of elements and links to remain unchanged in css

(Learning video sharing: css video tutorial)

The above is the detailed content of How to set the font of elements and links to remain unchanged in css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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