A cotton mask offers far less protection than a surgical mask. If a cloth mask is all you can find, buy a thick one. Snug-fitting masks made of cotton-polyester blends will generally offer more protection. But even a very good cloth mask may only be about 30% protective; scarf or bandanna, 10% or less.
A surgical mask could offer you better protection, on the order of 60%. But here again, quality matters. Many of the masks sold on Amazon, which say they are for dust and allergens, aren’t surgical masks, even though they look like the blue masks worn by nurses and doctors. A real medical-procedure mask will be cleared by the Food and Drug Administration and designated as offering one of three levels of protection. Generally, a level 2 or level 3 medical mask is best.
An N95 or equivalent mask offers the best protection and, if used properly, will filter out at least 95% of infectious particles. Online resources can help you fit the mask. In China the equivalent mask is the KN95 and in Europe the comparable designation is FFP2. The FDA has authorized for emergency use a bunch of KN95 and FFP2 masks that have been tested to show that they offer comparable protection to an N95 mask. These options are listed on the FDA’s website.