Socialist minister Francis J. Bellamy wrote the Pledge of Allegiance in the 1890s in an effort to paper over the post-Civil War divisions; to accompany it, he devised the "Bellamy Salute": "raise your right hand, flip your palm down, point it toward the flag in a salute and recite the words."
Fifty years later, Americans switched to holding their hands over their hearts, a gesture that was formally legislated in the US Flag Code in 1942, as Americans were struck with the hipster's horror of having their OG style ripped off by crass newcomers (Hitler, Mussolini, et al).
"At a signal from the Principal," Bellamy wrote, "the pupils, in ordered ranks, hands to the side, face the Flag. Another signal is given; every pupil gives the flag the military salute—right hand lifted, palm downward, to a line with the forehead and close to it. Standing thus, all repeat together, slowly, 'I pledge allegiance to my Flag…'" (The words of the Pledge itself have a long and contentious history of their own, as Amy Crawford wrote for Smithsonian magazine last year.)
The Rules About How to Address the U.S. Flag Came About Because No One Wanted to Look Like a Nazi
(via Super Punch)