简体   繁体   English

如何从链接中删除下划线?

[英]How do you remove underline from a link?

I am trying to remove an underline from links on a website.我正在尝试从网站上的链接中删除下划线。 I tried to use "text-decoration: none;"我尝试使用“文本装饰:无;” but it wouldn't work.但它不起作用。 What syntax did I do wrong?我做错了什么语法? or is there a better way to remove the underline?或者有没有更好的方法来删除下划线?

<head>
  <style>
    font {
      color: #ff9600;
      text-decoration: none;
    }
  </style>
</head>

<body>
  <a href="index.html">
    <font>Home</font>
  </a>
  <a href="watch.html">     
    <font>Watch</font>
  </a>
  <a href="info.html">
    <font>Info</font>
  </a>
</body>

You should use你应该使用

a {
  text-decoration: none;
}

in your stylesheet.在您的样式表中。 text-decoration is what adds the underline, and this code removes it. text-decoration添加下划线,此代码将其删除。


Side Note: Also, you should not be using the <font> tag, as it is obsolete . 旁注:另外,你不应该使用<font>标签,因为 它已经过时了 You should be using classes. 你应该使用类。

The reason that your code still has an underline, is because the Anchor tag <a> by default add the underline decoration to everything inside the tag.您的代码仍然有下划线的原因是因为锚标记 <a> 默认情况下将下划线装饰添加到标记内的所有内容中。 So you will have to apply the style to the "a" instead of the font - even though the font is inside the anchor.因此,您必须将样式应用于“a”而不是字体 - 即使字体位于锚点内。

<style>
    a {
       text-decoration: none;
     }
</style>

Try this:尝试这个:

<head>
  <style>
    font {
      color: #ff9600;
      text-decoration: none;
    }
    a {
      text-decoration: none;
    }
  </style>
</head>
<body>
  <a href="index.html">
    <font>Home</font>
  </a>
  <a href="watch.html">     
    <font>Watch</font>
  </a>
  <a href="info.html">
    <font>Info</font>
  </a>
</body>

check it out hope it would work..[![检查一下希望它会起作用..[![

 <head> <style> font { color: #ff9600; } a{ text-decoration: none; } </style> </head> <body> <a href="index.html"> <font>Home</font> </a> <a href="watch.html"> <font>Watch</font> </a> <a href="info.html"> <font>Info</font> </a> </body>

] 1 ] 1 ] 1 ] 1

Just move text-decoration: none;只需移动text-decoration: none; from font CSS to anchor tag a CSS.font CSS 到anchor tag a CSS。 Will resolve your issue.将解决您的问题。 Thanks谢谢

a {
  text-decoration: none;
}

 a { text-decoration: none; } font { color: #ff9600; }
 <a href="index.html"> <font>Home</font> </a> <a href="watch.html"> <font>Watch</font> </a> <a href="info.html"> <font>Info</font> </a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM