Can I accomplish this with CSS?

Viewed 150

If I've got elements like this:

<a href="something">A</a>
<a href="something_else">B</a>
<a href="something">A</a>
<a href="...">C</a>

I know I can use something like

body
{
    counter-reset:section;
}

a:before
{
    counter-increment:section;
    content:counter(section)". ";
}

to get

1. A
2. B
3. A
4. C

but is there a way to get the following?

1. A
2. B
1. A
3. C

ie. uniquely identify all links on a page by prefixing the text with the same number.

Note: hardcoding specific URLs isn't an option, I'm potentially dealing with hundreds of links and don't know the URLs ahead of time.

I realize this would be easy/possible with javascript, I am only interested in CSS-based solutions or an explanation of why this isn't possible with CSS.

5 Answers
Related