The tendency for two elements or substances to combine chemically. An example is the affinity of acid dyes for nylon fiber.