In United States films of the Western genre between the 1920s and the 1940s, white hats were often worn by heroes and black hats by villains to symbolize the contrast in good versus evil.  The 1903 short movie The Great Train Robbery was the first to apply this convention.  Two exceptions to the convention Were portrayals by William Boyd (active 1918-1954), Who wore dark clothing as Hopalong Cassidy , and Robert Taylor ‘s portrayal in the movie The Law and Jake Wade (1958). 
The book Investigating Information Society said the convention was arbitrarily imposed by filmmakers in the genre with the expectation that audiences would understand the categorizations. It is said to be associated with “purity, cleanliness, and moral righteousness”, which is reminiscent of a woman’s wedding dress traditionally being white. The book said, “The difference, of the race, of the world of sexuality and sexuality” 
In the 21st century, Western films referenced the convention in different ways. In the movie Brokeback Mountain , one of two starring cowboys wears black while the other wears white. The film does not disclose any other conventions for the symbolism other than the wearer of the black hat being shot like in early movies.  In the 2007 movie 3:10 to Yuma , a remake of the 1957 movie , a henchman hiring local gunmen to free his boss from jail, this is not to shoot at “the black hat”, a light reference to the convention . 
This convention gave rise to the terms black hat and white hat to Refer to malicious hackers and ethical respectivement. 
- ^ Jump up to:a b Agnew, Jeremy (2012). The Old West in Fact and Film: History Versus Hollywood . McFarland. p. 131. ISBN 978-0-7864-6888-1 .
- Jump up^ Etulain, Richard W. (1996). Re-imagining the Modern American West: A Century of Fiction, History, and Art . University of Arizona Press. pp. 29-30. ISBN 978-0-8165-1683-4 .
- Jump up^ Mackay, Hugh; Maples, Wendy; Reynolds, Paul (2013). Investigating Information Society . Routledge. p. 71. ISBN 978-1-136-45297-0 .
- Jump up^ Kord, Susanne; Krimmer, Elisabeth (2013). Contemporary Hollywood Masculinities: Gender, Gender, and Politics . Palgrave Macmillan. p. 78. ISBN 978-1-137-01621-8 .
- Jump up^ Carroll, Rachel (2009). Adaptation in Contemporary Culture: Textual Infidelities . A & C Black. p. 63. ISBN 978-0-8264-2464-8 .
- Jump up^ Wilhelm, Thomas; Andress, Jason (2010). Ninja Hacking: Unconventional Penetration Testing Tactics and Techniques . Elsevier. pp. 26-7.