Forum How do I...?

How to get the value of a string at a link target

pkjackson
Hi,

My HTML document has internal hyperlinks.

<a class="aLink" href="#id3765">link text</a>


We use the following to add page number references and it works:

.aLink::after { content: " [See page " target-counter(attr(href), page) "]"; }


Instead, I would like to change the text to include the closest heading number to the link target.

I can easily capture the heading number in a string using string-set, but I don't know how to retrieve the value of the string at the link taget. It like I need a function similar to target-counter, that returns the value of a string at that point instead of the value of a counter.

Is there a way to do this?
jpavel
pkjackson
Hi jpavel, thanks for responding.

I've used target-content() in other places but I don't think it will do what I need here. It gets the text content of a link. I need the value of a string at the point of the link.

howcome
The function you are looking for does not exist. Possibly, one could add target-string-value() or something in the future. But perhaps you're able to inject the content you are looking for into an element so that it can be fetched with target-content()?
pkjackson
Hi howcome, Yes - I though of that approach too. I can probably make it work, but I was hoping to find a CSS-only solution