Login
Remember
IF Answers
Ask a Question

# Twine with sugarcube: can you display visited links differently?

0 votes
222 views
asked Apr 14 in Authoring by peterorme (104 points)

In Twine (1.4) using the Sugarcube story format, is there some way to display links to visited passages so they look different from unvisited links? They are "a" html anchors, but using a an `a:visited` css selector does not cut it, I assume because the linking is done using javascript "click" events, not standard browser linking.

- twine
- sugarcube
- css

## 1 Answer

+2 votes
answered Apr 15 by peterorme (104 points)
Best answer

Allegedly `a:visited` doesn't work in any story format.

If you are using SugarCube you can use a trick.

Step 1. Enable visited link tracking with config.addVisitedLinkClass. Just create a script passage with the line

        config.addVisitedLinkClass = true;

This will start appending the `link-visited` CSS class to visited links.

Step 2. Add a stylesheet passage setting

        a.link-visited {
           color: purple;
        }

Kudos to TheMadExile who answered this question on Twinery.org forums.

## Related questions

- How do I pass variables between Twine and javascript?
- Twine: how can I check if a passage has been visited?
- Can you use custom CSS files with games uploaded to textadvenures.co.uk?
- How can I add changing maps or inventories to a Twine game?
- How can I find a good Twine game?

...