Dyes work by binding to specific molecular structures within cells and tissues. The binding is often based on the chemical properties of the dye and the biological component. For example, basic dyes bind to acidic structures due to electrostatic attraction, while acidic dyes bind to basic structures.