I'm trying to use target-counter
to describe references.
I found out about it from a List Apart article on making a book with HTML/CSS. There's only one other StackOverflow question and it didn't help me.
The attribute target-counter
is not recognised by Chrome, Firefox or Opera, but it's mentioned in the CSS2 spec and I can't find any other docs that say whether it's supported or not. So I can't tell if it's my code or the browser that's to blame.
You can see the code on this Dabblet snippet, or look at the snippets below.
My HTML:
<h1 id="foo">Root level</h1>
<p><a href="#bar">linking to bar</a> and stuff</p>
<h1 id="bar">Second heading</h1>
<h2 id="sub">Subhead</h2>
<p>Hey there <a href="#foo">with a link to foo</a></p>
And CSS:
h1 {
counter-increment: section;
}
h1::before {
content: counter(section) ". ";
}
a::after {
content: leader('.') target-counter(attr(href), section);
}
Any suggestions appreciated.