CSS text-decoration underline color [duplicate]

旧街凉风 提交于 2019-11-26 18:38:01
Rob

(for fellow googlers, copied from duplicate question) This answer is outdated since text-decoration-color is now supported by most modern browsers.


You most likely need this, by setting your word with a border-bottom.

a:link {
  color: red;
  text-decoration: none;
  border-bottom: 1px solid blue;
}
a:hover {
 border-bottom-color: green;
}
Cherusker

You can do it if you wrap your text into a span like:

a {
  color: #258;
  text-decoration: underline;
}
span {
  color: #d43;
  text-decoration: none;
}
<a href="#">
  <span>Text</span>
</a>
Luis

As far as I know it's not possible... but you can try something like this:

.underline 
{
    color: blue;
    border-bottom: 1px solid red;
}
<div>
    <span class="underline">hello world</span>
</div>

You can't change the color of the line (you can't specify different foreground colors for the same element, and the text and its decoration form a single element). However there are some tricks:

a:link, a:visited {text-decoration: none; color: red; border-bottom: 1px solid #006699; }
a:hover, a:active {text-decoration: none; color: red; border-bottom: 1px solid #1177FF; }

Also you can make some cool effects this way:

a:link {text-decoration: none; color: red; border-bottom: 1px dashed #006699; }

Hope it helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!