Static electricity occurs when there is an imbalance between positive and negative charges within or between objects. This can cause effects like receiving a shock from touching something after walking across a carpet. It is also responsible for phenomena like hair standing on end after removing a hat. Static electricity is the result of an imbalance of electric charges, which can build up until being discharged through a circuit or other object. Lightning is also a type of static electricity, where positive and negative charges separate within a thundercloud, building up a difference until discharging as lightning.