Avoiding penetrative sex or postponing is good for young persons until they find their permanent partner.
Mutually monogamous relationship in two healthy individuals carries zero risk of STIs.
The above methods may not be practical for some people If so by using condoms correctly and consistently they can prevent Sex. Alcohol and drugs should not be used before or during sex since they impair your ability to have safe sex. More info on Condoms
Novel HIV prevention methods
By taking HIV medications (ART) HIV can be prevented. HIV-negative partners can take HIV medications to prevent getting HIV. It is called Pre-exposure prophylaxis (PrRP) and Post Exposure Prophylaxis after Sexual Exposure. (PEPSE).