The U.S. Department of State issues visas in U.S. embassies and consulates abroad.
A visa does not guarantee entry into the United States.
A visa does allow a foreign citizen to travel to a U.S. port-of-entry and request permission from a U.S. immigration officer to enter the United States.
Did you know the U.S. Department of State issued 781,719 student and exchange visitor visas in fiscal year 2011? This translates to a worldwide acceptance rate of almost 86%. You will first need to receive an admission letter a certificate of eligibility for nonimmigrant student status from your U.S. institution before you can begin the visa application.
If you are going to the U.S. primarily for tourism, but want to take a short course of study that is recreational, and the course is less than 18 hours per week, you may be able to do so on a visitor (B) visa. When traveling to the U.S. to attend seminars, conferences or a program of study for academic credit then you will need a student visa. A consular officer will determine the visa category you will need based on the purpose of your travel, and your supporting documentation.
Many accredited U.S. colleges and universities now offer entire distance education programs of study entirely online. If you are accepted to one of these programs, you will not have to apply for a visa, since you physically will not be taking classes in the United States. However, if your online degree program requires you to take a seminar in the U.S. for academic credit, then you'll need a student visa. Again, a consular officer will determine the visa category you will need based on the purpose of your travel, and your supporting documentation.

