CSS - 嵌套锚标记链接

时间:2013-12-12 19:36:53

标签: css

我想在<a>代码

中创建嵌套链接

示例:

<a href="#">This is a link <a id="sup">sup text</a> end of the link</a>

的CSS:

a#sup{
    color:#19578e;
    font-family: Verdana;
    font-size: 8pt;
    vertical-align: top;
}

a {
    font-family: Arial;
    color: #19578e;
    font-size: 10pt;
    font-weight: normal;
    font-style: normal;
    text-decoration: none;
}

但是,只有“这是一个链接”指向链接......

2 个答案:

答案 0 :(得分:2)

由于Nested Links are illegal

,您在其他a代码中无法拥有a个代码

您可以使用<span>标记来使其正常工作:

<a href="#">This is a link <span id="sup">sup text</span> end of the link</a>

答案 1 :(得分:2)

使用SPAN,因为您无法嵌套锚标记。

<a href="#">This is a link <span id="sup">sup text</span> end of the link</a>
  

好的我会使用span,但是如何使span具有相同的功能   锚标记悬停时的锚标记?

将悬停状态添加到CSS中以获取“sup”元素。

a, a:hover #sup {
    font-family: Arial;
    color: #19578e;
    font-size: 10pt;
    font-weight: normal;
    font-style: normal;
    text-decoration: none;
}

如果你有这个以上的地方,你可以简单地使用:

a, a:hover span { ... }