Below the Radar
Below the Radar

Reputation: 7635

CSS - nested anchor tag link

I would like to create nested link inside a <a> tag

Example:

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

However, like that only the "This is a link" point to the link...

Upvotes: 0

Views: 1808

Answers (2)

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114377

Use a SPAN, since you cannot nest anchor tags.

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

Ok I'll use span, but how to make the span having the same propreties than anchor tag when anchor tag is hover ?

Add the hover state to your CSS for the "sup" element.

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

If you have this in more than on place, you can simply use:

a, a:hover span { ... }

Upvotes: 2

DaniP
DaniP

Reputation: 38252

You can't have a tags inside another a tag because Nested Links are illegal

You may use instead an <span> tag to make it work:

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

Upvotes: 2

Related Questions