While Hong Kong is in China, it is a special administrative region. This means it has its own visa policy. However, it is pretty lenient since 170 nationalities are visa-exempt and do not require a visa to enter the area. There are three main categories of people that need to meet some requirements to enter Hong Kong, not including the diplomats or other state officials. They have their own rules. The three categories are visa-exempt nationals, visa required nationals, and transit visa nationals.
As mentioned earlier, there are about 170 countries whose citizens can enter Hong Kong without a visa. However, they can only stay as long as the visa policy allows it. Depending on your nationality, you can stay in Hong Kong for up to 180 days, 90 days, 30 days, 14 days, and 7 days. You should do the proper research when you are planning a trip so that you know how much time you can spend in the region. If you need to stay for longer than the policy allows you, you need to apply for a visa at the nearest Chinese embassy or submit an application to HKSAR Immigration Department.
One exception is Indian nationals. Even though India is a visa-exempt country, Indians who travel to Hong Kong need to apply for a pre-arrival registration. That only applies if they want to stay in Hong Kong for up to 14 days. Otherwise, they need to apply for a consular visa. Fortunately, the process of getting the registration is entirely online, and there is no significant effort whatsoever.
Visa-exempt nationals aside, the citizens of 19 countries actually need to apply for a Hong Kong visa before departure. The request can be made at the nearest Chinese embassy or at the HKSAR Immigration Department. The requirements are not inaccessible. All you need is a passport that has a validity of at least another 6 months, some photos, and you need to fill in an application form. The process can take up to 4 weeks. People in the same category does not require a visa if they only wish to transit in Hong Kong. However, they are not allowed to leave the airport transit area.
29 nationalities need to apply for a Hong Kong transit visa even if they have no intention of leaving the airport transit area.
As you can imagine, Hong Kong releases visas for other purposes as well. You can get a visa for investment, education, and even work, but you need to apply for the right one. Otherwise, your entry will be refused and you will be deported. One particular aspect worth mentioning is that the citizens of 16 states who are holders of an APEC Business Travel Card that contains the code HKG on the back are allowed to stay in Hong Kong up to 60 days without a visa.
While the Hong Kong visa policy is a lot more extensive than what you find above, at least you have a clearer picture now for sure. Usually, getting a Hong Kong visa for tourists is easy, and chances of not requiring one at all are pretty high. Even so, it is always best if you are informed.