Here’s a tiny, tiny CSS micro-snippet which I found and just had to share…
We all know about using a hash anchor link to jump down a page to a specific element. You know:
<a href="#element">
Well, did you also know that you can target this element in CSS which you have just jumped to using a special selector like this?
#element:target {... styles here ...}
How neat is that? A really nice way of highlighting a specific element which has been “jumped-to” at some point further down the page. I think this is good for usability and accessibility as it could be used to guide users to the fact that they have scrolled to a location that’s not, as expected, at the top of the page. I suspect this is used by Stack Overflow to highlight specific comments when linking to them directly.
I think this is pretty neat, and will be looking at integrating it into my future projects.