Today, more tools than ever are available to prevent HIV. Strategies such as abstinence (not having sex), limiting number of sexual partners, never sharing needles, and using condoms the right way every time you have sex. There are also HIV prevention medicines such as pre-exposure prophylaxis (PrEP) and post-exposure prophylaxis (PEP).
If you have HIV, there are many actions you can take to prevent transmitting it to others. The most important is taking HIV medicine (called antiretroviral therapy, or ART) as prescribed. If you take HIV medicine as prescribed and get and keep an undetectable viral load (or stay virally suppressed), you can stay healthy and have effectively no risk of transmitting HIV to an HIV-negative sex partner.