首页 > 解决方案 > 如何将超链接与 javascript 或 css 分开设置?

问题描述

如何将超链接与 javascript 或 css 分开设置?但我不想为每个人创建一个新的类或 id。在我问这个问题之前我已经尝试过搜索,但我不知道正确的终端,对不起我的英语不好

编辑:

我的意思是,对于 2 个超链接(例如,点就是区别):

<a href=https://www.google.com>google</a>
<a href=www.google.com>google, no http</a>

样式不同,但前提是超链接类型不同

标签: javascripthtmlcsshyperlink

解决方案


您可以通过像这样应用元素级 css 来简单地做到这一点

a {
  color: red;
  font-weight: bold;
}
<div>
  <p>Normal Text</p>
  <p><a href="#"> This is hyperlink </a></p>
  <p><a href="#"> This is another hyperlink </a></p>
  <p><a href="#"> This is another hyperlink </a></p>
  <p> <a href="#"> This is another hyperlink </a></p>
  <p><span> Normal Text</span></p>
</div>


推荐阅读