@EllyCobbett, I'm looking for the same solution. I would love to know if you ever get it to work?
I want to italicize certain posts based on the category. I really thought you could use css to target adjacent items, but the category name is just to deep in the structure to enable it.
I found some javascript code but it didn't work for me. StackOverflow: https://stackoverflow.com/questions/66090012/squarespace-change-css-elements-depending-on-blog-tag