Yes, sunscreen can prevent tanning when used correctly. It significantly reduces the amount of UV radiation that reaches your skin, which is what causes tanning. While it's impossible for sunscreen to block 100% of UV rays, applying it regularly and reapplying every two hours or after swimming or sweating helps minimize UV exposure and the likelihood of tanning.
While a tan may still be possible with sunscreen, it will be less noticeable and less damaging to your skin. Sunscreen protects your skin from sunburn and the long-term damage that can lead to skin cancer.
In summary, sunscreen is a vital tool for protecting your skin from the sun's harmful rays, including those that cause tanning.