Onions contain some natural chemicals. when you slice an onion, these chemicals are released into the air and these get into your eyes . This makes your eyes sting and tears come out of your eyes. The harsh chemicals in an onions contain sulphur. It is sulphur which is responsible for stinging action.
Sulphur has very strange and sharp smell. It is found in everyday items such as fireworks, paints, detergents , egg yolk and in some medicine too.