Term derived from old Western movies wherein the villain was usually protrayed as wearing a black hat, whereas the hero was usually wearing a white hat.

Not related to Red Hat.