It's called 'static electricity,' and it happens when a few electrons get pulled off the atoms in your hair and onto your hat. That leaves your hair with not quite enough electrons. ... Positive charges repel each other, so your charged hairs repel each other and stand out from your head.