How can I add a class to a div when I visit a page in my website and save this on cache?

For example: I have a index.html that looks like this: <https://i.stack.imgur.com/6iJEr.png>

What I wanna do is when someone click in one div (witch is linked to a page like page3.hml) this div will add a class and save in cache, so when back to index.html this div will still have this class. Like this: <https://i.stack.imgur.com/lMjZG.png>

The class wold be something like

```
.visited{
border-bottom: 10px solid red;
}

```

Is this possible?
Sorry for my English :(