The difference between stainless steel and carbon steel
Stainless steel differs from carbon steel by the amount of chromium present. Unprotected carbon steel rusts readily when exposed to air and moisture. This iron oxide film (the rust) is active and accelerates corrosion by making it easier for more iron oxide to form. Since iron oxide has lower density than steel, the film expands and tends to flake and fall away.
In comparison, stainless steels contain sufficient chromium to undergo passivation, forming an inert film of chromium oxide on the surface. This layer prevents further corrosion by blocking oxygen diffusion to the steel surface and stops corrosion from spreading into the bulk of the metal. Passivation occurs only if the proportion of chromium is high enough and oxygen is present.