简体   繁体   English

如何删除我的 HTML email 中的链接下划线?

[英]How do I remove link underlining in my HTML email?

<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.我使用此代码在我的 HTML email 中建立链接。在浏览器和 Outlook 中它运行良好,但在 GMail、Hotmail 和 ymail 中它显示带下划线的链接。

Can anyone help me to get rid of this?谁能帮我摆脱这个?

<a href="#" style="text-decoration:none !important; text-decoration:none;">BOOK NOW</a>

Outlook will strip out the style with !important tag leaving the regular style, thus no underline. Outlook 将删除带有!important标签的样式,保留常规样式,因此没有下划线。 The !important tag will over rule the web based email clients' default style, thus leaving no underline. !important标签将覆盖基于 Web 的电子邮件客户端的默认样式,因此不会留下下划线。

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/ http://www.campaignmonitor.com/css/

It's worth noting that GMail and Outlook are two of the pickiest to format HTML email for.值得注意的是,GMail 和 Outlook 是两种最挑剔的 HTML 电子邮件格式。

在文本修饰规则中使用!important

<a href="#" style="text-decoration:none !important;">BOOK NOW</a>

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.经过半天的研究(以及这个问题提出两年后),我相信我已经找到了一个全面的答案。

<a href="#"><font color="#000000"><span style='text-decoration:none;text-underline:none'>Link</span></font></a>

(You need the text-underline property on the span inside the link and the font tag to edit the colour) (您需要链接内跨度上的 text-underline 属性和字体标签来编辑颜色)

Another way to fool Gmail (for phone numbers): use a ~ instead of a -另一种欺骗 Gmail 的方法(对于电话号码):使用 ~ 而不是 -

404-835-9421 --> 404~835~9421 404-835-9421 --> 404~835~9421

It'll save you (or less savvy users ;-) the trip down html lane.它将为您(或不太精明的用户;-)节省 html 通道。

I found another way to remove links in outlook that i tested so far.我找到了另一种方法来删除迄今为止我测试过的 Outlook 中的链接。 if you create a blank class for example in your css say .blank {} and then do the following to your links for example:例如,如果您在 css 中创建一个空白类,请说 .blank {} 然后对您的链接执行以下操作,例如:

<a href="http://www.link.com/"><span class="blank" style="text-decoration:none !important;">Search</span></a>

this worked for me hopefully it will help someone who is still having trouble taking out the underline of links in outlook.这对我有用,希望它能帮助那些仍然无法删除 Outlook 中链接下划线的人。 If anyone has a workaround for gmail please could you help me tried everything in this thread nothing is working.如果有人有 gmail 的解决方法,请您帮我尝试此线程中的所有内容,但没有任何效果。

Thanks谢谢

I think that if you put a span style after the <a> tag with text-decoration:none it will work in the majority of the browsers / email clients.我认为,如果您在<a>标签后放置一个带有text-decoration:none的 span 样式,它将适用于大多数浏览器/电子邮件客户端。

As in:如:

<a href="" style="text-decoration:underline">
    <span style="color:#0b92ce; text-decoration:none">BANANA</span>
</a>

I added both declarations on the a href which worked in outlook and gmail apps.我在 Outlook 和 Gmail 应用程序中的 a href 上添加了两个声明。 outlook ignores the !important and gmail needs it. Outlook 忽略了 !important 并且 gmail 需要它。 Web versions of email work with both/either.电子邮件的 Web 版本适用于两者。

text-decoration: none !important; text-decoration: none;

Windows Mail seemed to outright ignore inline text-decoration tag but what fixed it for me was by adding this to the head: Windows Mail 似乎完全忽略了内联text-decoration标签,但对我来说修复它的是通过将其添加到头部:

<!--[if (mso)|(mso 16)]>
<style type="text/css">
    body, table, td, a, span { font-family: Arial, Helvetica, sans-serif !important; }
    a {text-decoration: none;}
</style>
<![endif]-->

All email clients adjust the HTML and the CSS code you provide by their own rules:所有电子邮件客户端都会根据自己的规则调整您提供的 HTML 和 CSS 代码:

eg: gmail removes everything but the inner HTML of the body tag.例如:gmail 会删除除正文标签的内部 HTML 之外的所有内容。

1. for most other clients you can have a style-tag in your header 1.对于大多数其他客户,您可以在标题中添加样式标签

<style type="text/css">
    a {text-decoration: none !important;}
</style>

note: don't use CSS comments as YAHOO!Mail might cause trouble.注意:不要使用 CSS 注释,因为 YAHOO!Mail 可能会引起麻烦。

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) 2. 在保存方面,将相同的代码内联添加到 A 标签中,以及一个额外的 span 标签(标签中的样式规则经常被删除)

<a href="" style="text-decoration: none !important;">
    <span style="text-decoration: none !important;">
        text
    </span>
</a>

To completely "hide" underline for <a> in both mail application and web browser, can do the following tricky way.要在邮件应用程序和 Web 浏览器中完全“隐藏” <a>下划线,可以执行以下棘手的方法。

<a href="..."><div style="background-color:red;">
    <span style="color:red; text-decoration:underline;"><span style="color:white;">BUTTON</span></span>
</div></a>
  1. Color in 1st <span> is the one you don't need, MUST set as same as your background color.第一个<span>中的颜色是您不需要的颜色,必须设置为与您的背景颜色相同。 (red in here) (此处为红色)

  2. Color in 2nd <span> is the one for your button text.第二个<span>中的颜色是按钮文本的颜色。 (white in here) (此处为白色)

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:文本修饰 none 对我不起作用,然后我在 Outlook 中找到了一封没有该行的电子邮件并检查了代码:

<span style='font-size: 12px; font-family: "Arial","Verdana", "sans-serif"; color: black; text-decoration-line: none;'>
<a href="http://www.test.com" style='font-size: 9.0pt; color: #C69E29; text-decoration: none;'><span>www.test.com</span></a>
</span>

This one is working for me.这个对我有用。

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.我使用了在 google 中不显示链接、为 mso (outlook) 添加链接和害羞标签的组合,以保持我公司的外观和感觉。 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)一些代码可能是多余的(对于我的公司来说,外观比可点击部分更重要。(感觉就像一个拼图,因为每一个变化都会阻碍其他东西)

<td style="color:rgb(69, 54, 53)">
<!--[if gte mso 9]>
<a href="http://www.immothekerfinotheker.be" style="text-decoration:none;">
<span style="text-decoration:none;">
<![endif]-->
www&shy;.&shy;immothekerfinotheker&shy;.&shy;be
<!--[if gte mso 9]>
</a>
</span>
<![endif]-->
</td>

Hope this helps someone希望这有助于某人

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:截至目前,正文中的样式仅支持:

  • Outlook 2007/10/13 +展望 2007/10/13 +
  • Outlook 2000/03展望 2000/03
  • Apple iPhone/iPad苹果 iPhone/iPad
  • Outlook.com展望网
  • Apple Mail 4苹果邮件 4
  • Yahoo!雅虎! Mail Beta邮件测试版

http://www.campaignmonitor.com/css/ http://www.campaignmonitor.com/css/

Use text-decoration:none !important;使用text-decoration:none !important; instead of text-decoration:none;而不是text-decoration:none; to make sure you "lose" the underline.以确保您“丢失”下划线。

Here in http://www.campaignmonitor.com/css/ , a nice explanation to say this is restricted!http://www.campaignmonitor.com/css/ 中,一个很好的解释说明这是受限制的! And a pretty nice guide to know all limitations of CSS in email clients.还有一个非常好的指南,可以了解电子邮件客户端中 CSS 的所有限制。

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:例子:

<td width="110" align="center" valign="top" style="color:#000000;">
    <a href="https://example.com" target="_blank"
       style="color:#000000; text-decoration:none;"><span style="color:#000000; text-decoration:none;">BOOK NOW</span></a>
</td>

While viewing the html email try inspecting the element on that link and see what is overwriting it.在查看 html 电子邮件时,尝试检查该链接上的元素,看看是什么覆盖了它。 Use that class and define it that style again in your head style and define the text-decoration: none !important;使用该类并在您的头部样式中再次定义该样式并定义 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.就我而言,这些是覆盖我的内联样式的类,因此在我的 html 电子邮件的头部声明了这一点,并定义了我想要实现的样式。

It worked for me, hope it will work on your one too.它对我有用,希望它也适用于你的。

.ii a[href]{
text-decoration: none !important;
}

#yiv8915438996 a:link, #yiv8915438996 span.yiv8915438996MsoHyperlink{
text-decoration: none !important;
}   

#yiv8915438996 a:visited, #yiv8915438996 span.yiv8915438996MsoHyperlinkFollowed{
text-decoration: none !important;
}   

Code like the lines below worked for me in Gmail Web client.下面几行的代码在 Gmail Web 客户端中对我有用。 A non-underlined black link showed up in the email.电子邮件中出现了一个无下划线的黑色链接。 I didn't use the nested span tag.我没有使用嵌套的span标签。

<table>
  <tbody>
    <tr>
        <td>
            <a href="http://hexinpeter.com" style="text-decoration: none; color: #000000 !important;">Peter Blog</a>
        </td>
    </tr>
  </tbody>
</table>

Note: Gmail will strip off any incorrect inline styles.注意:Gmail 会去除任何不正确的内嵌样式。 Eg code like the line below will have its inline styles all stripped off.例如,像下面这样的代码将全部剥离其内联样式。

<a href="http://hexinpeter.com" style="font-family:; text-decoration: none; color: #000000 !important;">Peter Blog</a>

I copied my html page and pasted to word.我复制了我的 html 页面并粘贴到 word 中。 Edited the signature in word deleting the spaces where the underline is placed and make my own "padding" presssing space bar.编辑 word 中的签名,删除放置下划线的空格,并按空格键制作我自己的“填充”。 Copied again and pasted to Outlook 2013. Worked fine for me.再次复制并粘贴到 Outlook 2013。对我来说效果很好。

In Windows 10 Mail, you might need to add these in your html head:在 Windows 10 邮件中,您可能需要在 html 头中添加这些:

<!--[if (mso)|(mso 16)]>
  <style type="text/css">
    body, table, td, a, span { font-family: Arial, Helvetica, sans-serif !important; }
    a {text-decoration: none;}
  </style>
<![endif]-->

The 'a {text-decoration: none;}' fixed the underline problems :) 'a {text-decoration: none;}' 修复了下划线问题:)

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.在我的例子中,我使用 Safari 配置了签名(复制并粘贴到 gmail 中)。我尝试了你放在这里的每一个代码,但这些都没有用。 After you paste the signature using Safari, you can come back to Chrome and the underline is gone.使用 Safari 粘贴签名后,您可以返回 Chrome,下划线消失了。

您所要做的就是:

<a href="" style="text-decoration:#none; letter-spacing: -999px;">

place your "a href" tag without any styling before div / span of text.在 div / span of text 之前放置没有任何样式的“a href”标签。 then make your styling in the div/span tag.然后在 div/span 标签中制作你的样式。

for the most restricted styling email client.适用于最受限制的样式电子邮件客户端。

<div><a href=""><span style="text-decoration:none">title</span><a/></div>

你应该写这样的东西。

<a href="#" style="text-decoration:none;">BOOK NOW</a>

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

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