如何删除 HTML 电子邮件中的链接下划线?
<td width="110" align="center" valign="top" style="color:#000000;">
<a href="https://example.com" target="_blank"
style="color:#000000; text-decoration:none;">BOOK NOW
</a>
</td>
我使用此代码在我的 HTML 电子邮件中创建了一个链接。在浏览器和 Outlook 中,它运行良好,但在 GMail、Hotmail 和 ymail 中,它会显示带下划线的链接。
谁能帮我摆脱这个?
<td width="110" align="center" valign="top" style="color:#000000;">
<a href="https://example.com" target="_blank"
style="color:#000000; text-decoration:none;">BOOK NOW
</a>
</td>
I used this code to make a link in my HTML email. In browsers and Outlook it's working nicely, but in GMail, Hotmail, and ymail it shows links underlined.
Can anyone help me to get rid of this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(27)
Outlook 将删除带有
!important
标记的样式,保留常规样式,因此没有下划线。!important
标签将覆盖基于网络的电子邮件客户端的默认样式,因此不会留下下划线。Outlook will strip out the style with
!important
tag leaving the regular style, thus no underline. The!important
tag will over rule the web based email clients' default style, thus leaving no underline.我看到这个问题已经得到解答;但是,我认为此链接提供了有关各种电子邮件客户端支持的格式的适当信息。
http://www.campaignmonitor.com/css/
值得注意的是,GMail 和 Outlook 是其中的两个最挑剔的 HTML 电子邮件格式。
I see this has been answered; however, I feel this link provides appropriate information for what formatting is supported in various email clients.
http://www.campaignmonitor.com/css/
It's worth noting that GMail and Outlook are two of the pickiest to format HTML email for.
经过半天的研究(自这个问题提出以来已有两年),我相信我已经找到了一个全面的答案。
(您需要链接内跨度上的 text-underline 属性和字体标签来编辑颜色)
After half a day looking into this (and 2 years since this question was opened) I believe I have found a comprehensive answer to this.
(You need the text-underline property on the span inside the link and the font tag to edit the colour)
Windows Mail 似乎完全忽略了内联
text-decoration
标签,但对我来说解决这个问题的方法是将其添加到头部:Windows Mail seemed to outright ignore inline
text-decoration
tag but what fixed it for me was by adding this to the head:在文本修饰规则中使用
!important
。Use
!important
in the text decoration rule.另一种欺骗 Gmail(电话号码)的方法:使用
〜而不是
-
404-835-9421 --> 404~835~9421
它将帮助您(或不太精明的用户;-)沿着 html 通道前进。
我找到了另一种方法来删除迄今为止我测试过的 Outlook 中的链接。例如,如果您在 css 中创建一个空白类,例如 .blank {},然后对您的链接执行以下操作:
这对我有用,希望它能帮助那些仍然无法在 Outlook 中取出链接下划线的人。如果有人有 Gmail 的解决方法,请帮我尝试一下这个线程中的所有内容,但没有任何效果。
谢谢
Another way to fool Gmail (for phone numbers): use a
~ instead of a
-
404-835-9421 --> 404~835~9421
It'll save you (or less savvy users ;-) the trip down html lane.
I found another way to remove links in outlook that i tested so far. if you create a blank class for example in your css say .blank {} and then do the following to your links for example:
this worked for me hopefully it will help someone who is still having trouble taking out the underline of links in outlook. If anyone has a workaround for gmail please could you help me tried everything in this thread nothing is working.
Thanks
我认为,如果您在带有
text-decoration:none
的标记后面放置一个 span 样式,它将在大多数浏览器/电子邮件客户端中工作。
如:
I think that if you put a span style after the
<a>
tag withtext-decoration:none
it will work in the majority of the browsers / email clients.As in:
我在 a href 上添加了这两个声明,这些声明适用于 Outlook 和 Gmail 应用程序。 Outlook 会忽略 !important,而 Gmail 需要它。电子邮件的网络版本可以同时使用。
I added both declarations on the a href which worked in outlook and gmail apps. outlook ignores the !important and gmail needs it. Web versions of email work with both/either.
要在邮件应用程序和网络浏览器中完全“隐藏”
的下划线,可以执行以下巧妙的方法。
第一个
中的颜色是您不需要的颜色,必须设置为与背景颜色相同。 (此处为红色)
第二个
中的颜色是按钮文本的颜色。 (此处为白色)
To completely "hide" underline for
<a>
in both mail application and web browser, can do the following tricky way.Color in 1st
<span>
is the one you don't need, MUST set as same as your background color. (red in here)Color in 2nd
<span>
is the one for your button text. (white in here)文本装饰没有一个对我不起作用,然后我在 Outlook 中发现一封没有该行的电子邮件并检查了代码:
这个对我有用。
Text decoration none was not working for me, then i found an email in outlook that did not have the line and checked the code:
This one is working for me.
我使用了不在谷歌中显示链接、添加 mso(outlook)链接和害羞标签的组合,以保持我公司的外观和感觉。有些代码可能是多余的(对于我的公司来说,外观比可点击的部分更重要。(感觉就像拼图,因为每次更改都会制动其他东西)
希望这对某人有帮助
I used a combination of not showing links in google, adding links for mso (outlook) and the shy tag, to keep the looks and feels for my company. Some code may be redundant (for my company the looks where more important then the be clickable part. (it felt like a jigsaw, as every change brakes something else)
Hope this helps someone
所有电子邮件客户端都会调整您提供的 HTML 和 CSS 代码
他们自己的规则:
例如:gmail 删除除 body 标记的内部 HTML 之外的所有内容。
1. 对于大多数其他客户端,您可以在标头中添加样式标签
注意:不要使用 CSS 注释,因为 YAHOO!Mail 可能会造成麻烦。
2.为了保存,将相同的代码内联添加到A标签中,就像你所做的那样,以及一个额外的span标签(标签中的样式规则经常被删除)
All email clients adjust the HTML and the CSS code you provide by
their own rules:
e.g.: gmail removes everything but the inner HTML of the body tag.
1. for most other clients you can have a style-tag in your header
note: don't use CSS comments as YAHOO!Mail might cause trouble.
2. to be on the save side add the same code inline into the A tag as you did and an extra span tag as well (the style rules in a tags get often removed)
在 Windows 10 邮件中,您可能需要在 html 头部添加这些内容:
'a {text-decoration: none;}' 修复了下划线问题:)
In Windows 10 Mail, you might need to add these in your html head:
The 'a {text-decoration: none;}' fixed the underline problems :)
这完全取决于电子邮件客户端是否要在链接下显示下划线。截至目前,正文中的样式仅支持:
http://www.campaignmonitor.com/css/
It wholly depends on the email client whether it wants to display the underline under the link or not. As of now, the styles in the body are only supported by:
http://www.campaignmonitor.com/css/
使用
text-decoration:none !important;
而不是text-decoration:none;
来确保您“失去”下划线。Use
text-decoration:none !important;
instead oftext-decoration:none;
to make sure you "lose" the underline.在 http://www.campaignmonitor.com/css/ 中,一个很好的解释是受限制的!这是一个非常好的指南,帮助您了解电子邮件客户端中 CSS 的所有限制。
Here in http://www.campaignmonitor.com/css/, a nice explanation to say this is restricted! And a pretty nice guide to know all limitations of CSS in email clients.
您可以执行“冗余样式”,这应该可以解决问题。您可以使用与 中相同的样式,但将其添加到 中的 中。
例子:
You can do "redundant styling" and that should fix the issue. You use the same styling you have on the but add it to a that is within the .
Example:
查看 html 电子邮件时,尝试检查该链接上的元素,看看是什么覆盖了它。使用该类并在您的头部样式中再次定义该样式并定义文本装饰:none !important;
就我而言,这些类会覆盖我的内联样式,因此在我的 html 电子邮件的头部声明了这一点,并定义了我想要实现的样式。
它对我有用,希望对你也有用。
While viewing the html email try inspecting the element on that link and see what is overwriting it. Use that class and define it that style again in your head style and define the text-decoration: none !important;
In my case these are the classes that are overwriting my inline style so declared this on the head of my html email and defined the style that I want implemented.
It worked for me, hope it will work on your one too.
下面的代码在 Gmail Web 客户端中对我有用。电子邮件中出现了一个无下划线的黑色链接。我没有使用嵌套的
span
标签。注意:Gmail 将删除任何不正确的内联样式。例如,如下行代码将其内联样式全部删除。
Code like the lines below worked for me in Gmail Web client. A non-underlined black link showed up in the email. I didn't use the nested
span
tag.Note: Gmail will strip off any incorrect inline styles. E.g. code like the line below will have its inline styles all stripped off.
我复制了 html 页面并粘贴到 word 中。
在word中编辑签名,删除放置下划线的空格,并按空格键制作我自己的“填充”。
再次复制并粘贴到 Outlook 2013。
对我来说效果很好。
I copied my html page and pasted to word.
Edited the signature in word deleting the spaces where the underline is placed and make my own "padding" presssing space bar.
Copied again and pasted to Outlook 2013.
Worked fine for me.
就我而言,我使用 Safari 配置了签名(在 Gmail 中复制并粘贴)。我尝试了您放在这里的所有代码,但这些代码不起作用。使用 Safari 粘贴签名后,您可以返回 Chrome,下划线就会消失。
In my case, I configured the signature (copy and paste in gmail) using Safari. I tried every code you putted here, but those didn´t worked. After you paste the signature using Safari, you can come back to Chrome and the underline is gone.
在元素样式内使用
text-decoration: unset;
适用于GMAILUsing
text-decoration: unset;
inside the style of the element works for GMAIL只需使用以下 css 即可避免锚标记默认 css 样式:
Just use the following css to avoid anchor tag default css styling:
我尝试了上面所有的解决方案,但没有任何效果。我将一张卡片包裹在锚标记内,无论我做什么,卡片内的文本总是带有下划线。所以我所做的就是用锚标记将卡片内的每个文本包裹起来,并分配
text-decoration: underline; text-decoration-color: #FFFFFF;
锚标记的样式。因为#FFFFFF
是卡片的背景颜色,下划线也消失了。如果
#FFFFFF
不是您的背景颜色,请将其更改为您需要的任何颜色。i tried all the solution above nothing worked. i was wrapping a card inside an anchor tag and no matter what i did the text inside the card always had underline. so what i did was wrap every text inside the card with an anchor tag and assign
text-decoration: underline; text-decoration-color: #FFFFFF;
styles to the anchor tag. as#FFFFFF
was the background color of the card as well the underline disappeared.if
#FFFFFF
is not your background color change it to whatever you need.您所要做的就是:
All you have to do is:
将“a href”标签放置在文本的 div / span 之前,不带任何样式。
然后在 div/span 标签中设置样式。
对于样式最受限制的电子邮件客户端。
place your "a href" tag without any styling before div / span of text.
then make your styling in the div/span tag.
for the most restricted styling email client.
你应该写这样的东西。
You should write something like this.