Styes are caused by an infection at the base of an eyelash follicle. They are not dangerous in themselves and usually resolve without any treatment per se. Sometimes a warm compress can help relieve some of the pain and it is thought that they may help the infection resolve faster - though it hasn't necessarily been proven. Either way, to make a warm compress simply run a clean cloth or cotton ball under warm water and then place it on the infected eye for a few minutes (with the infected eye closed). Make sure you either wash that cloth or throw the cotton ball away afterwards to prevent the infection spreading.
As styes are easily spread the best preventative measure to ensure no one else in the house gets them (and to ensure that you don't get more than one stye at a time) is to avoid touching them. This can be quite hard to do sometimes as they are red, sore and irritated - but try your absolute best to leave it alone. If you do touch it, make sure you wash your hands afterwards.
Styes will often come to a white head and people can be tempted to burst this - it is important that you leave it alone! The pus that escapes may cause another infection in the eye and further along in the eyelash. Sometimes people can get many styes in a row on the same eye. If this happens then antibiotics may be required and I'd suggest you see your doctor.
Sometimes people confuse a blocked oil gland infection with a stye. If the eye lid itself gets inflamed but there is no obvious eye lash involvement, then it could be that you are experiencing this instead. Like a stye, this is not dangerous and will resolve by itself. Sometimes people will become susceptible to repeated oil gland infections which can get bothersome - in these cases see your optometrist as you may require some antibiotic eye drops/eye ointment.
Last but not least, one of the most common times people get styes is during or just after a cold. This is because the secretions from their nose can carry bacteria and it is common (especially in children) to get some of the snot on a finger or tissue that then touches their eye. To avoid this happening make sure hands are regularly washed when anyone in the house has a cold, and that used tissues are put straight in the bin.