The clouds are massive groups of water droplets. In the tops of the clouds, temperature is below freezing and the water vapour turns into ice. Lots of small bits of ice collides each other as they move around. All these collisions cause a build up of electrical charge. When they collide with each other, they create a massive charge in them. Lighter, positively charged particles form at the top of the cloud. Heavier, negatively charged particles sink to the bottom of the cloud. When the positive and negative charges grow large enough, the electricity is discharged as a bolt of lightning within the cloud. Most lightning happens inside a cloud, but sometimes it happens between the cloud and the ground. Lightning also occurs when a charged cloud comes in contact with another oppositely charged cloud.