Cotton and nylon are both water absorbent because of their molecular structures and how those structures interact with water molecules. Cotton is made primarily from cellulose, which is a carbohydrate produced by plants.
Cellulose comes from a family of carbohydrates known as polysaccharides.
Polysaccharides are long chains of simple sugars that contain several hydroxyl groups on each sugar. These hydroxyl groups interact very strongly with water because of the polarity of the oxygen-hydrogen bond. A single molecule of cellulose can contain hundreds of hydroxl groups. The affinity that nylons have for water also comes from polar bonds. This bond is typically formed between a carboxylic acid and an amine, and contains carbon, oxygen, nitrogen, and hydrogen atoms.