2013-12-12 55 views
0

我想创建一个<a>标签内嵌套链接CSS - 巢式锚标记链接

例子:

<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; 
} 

然而,这样只有“这是一个链接“指向链接...

+1

不能嵌套另一个锚内的锚。 –

+2

您不能嵌套定位标记。这是无效的HTML。使用SPAN。 –

回答

2

使用SPAN,因为你不能嵌套锚标记。

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

好,我将使用范围,但如何让具有相同propreties 比当锚标记为悬停定位标记的跨度?

将悬停状态添加到您的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 { ... } 
+0

好吧我会使用跨度,但是如何在锚标签悬停时如何使跨度具有与锚标签相同的属性? –

2

你不能有a标签内的anot她a标签,因为Nested Links are illegal

您可以改为使用一个<span>标签,使其工作:

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