XPath allows interacting with any element's attribute such as class, id, href and any other through the @ syntax.
Attribute values then can be used in predicates using = or contains(). See these interactive examples:
Select attribute value, like the urls of <a> links:
Or filter element based by attribute using contains() function: