Since bacterial infections seriously threaten human's health, considerable attention is devoted to the design of nanoscale antibacterial materials. Among them, metal nanoparticles cannot meet the requirements of durable antibacterial effects and are harmful to biological environments. In this study, environmentally friendly nanogels with durable antibacterial and antiadhesion properties are prepared by copolymerization of styrene, polycaprolactone‐hydroxyethyl methacrylate, and polyhexamethylene guanidine hydrochloride methacrylate. The resultant nanogels possess regular spherical morphologies with the size of about 200 nm. The nanogels exhibit a strong ability to kill bacteria and the mechanism is different from that of conventional antibacterial agent loaded nanoparticles. In addition, anti‐infection experiments explored by a wound model confirm the nanogels have the capability to prevent infection. Furthermore, the nanogels grafted on the surface of cotton fibers display good thermal stability, which is essential for finishing of fabrics. The cotton fabrics finished with nanogels can prevent the adhesion of bacteria by enhancing the hydrophobicity and the bacteriostatic rate. The antibacterial fabrics against Staphylococcus aureus and Escherichia coli are still more than 86% active after 50 times of mechanical washing. The biocompatible nanogels are unleachable from the antibacterial fabrics which demonstrate that they are ideal candidates for durable and environmental‐friendly nanoscaled antimicrobial materials.