简体   繁体   English

在CSS中用红色下划线

[英]Underline in a text with red color in CSS

I want to write an underline with font color red. 我想用红色字体写一个下划线。

I Tried like this 我试过这样

 <u> <li style="COLOR:red"><a href="/jobs.aspx/"> Internal Job Openings </a></li></u>

But the content is hiding. 但是内容是隐藏的。 How to fix this? 如何解决这个问题?

You need to override the default style for a as well: 你需要重写默认样式a ,以及:

<ul>
    <li style="color:red"><a style="color:red" href="#">foo</a></li>
</ul>

see the fiddle.... 看到小提琴...

First of all, your HTML is invalid. 首先,您的HTML无效。 You cannot enclose a <li> inside a <u> tag. 您不能将<li>括在<u>标记内。 And remove the <u> tag as it is deprecated. 并删除不推荐使用的<u>标记。 Use the CSS's color and text-decoration rules to achieve your result. 使用CSS的colortext-decoration规则来实现您的结果。

Change it to this way: 更改为这种方式:

<li style="COLOR:red; text-decoration: underline;">
    <a href="/jobs.aspx/"> Internal Job Openings </a>
</li>

If you just need it for the link, then give the style to the link. 如果您仅需要链接,则将样式指定给链接。

<li style="COLOR:red;">
    <a style="text-decoration: underline;" href="/jobs.aspx/"> Internal Job Openings </a>
</li>

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

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