"The Star-Spangled Banner" has been recognized as the U.S. national anthem since 1931. U.S. Code § 301 addresses the proper etiquette for U.S. citizens to follow when the anthem plays.
Hand Over Heart
When the anthem plays, a U.S. citizen should rise from his seat, stand at attention, face the flag and place his right hand over his heart. This etiquette also applies to children who are old enough to stand on their own. The Emily Post Institute notes that if a citizen is walking to her seat when the anthem begins to play, she should stop walking, stand at attention and place her hand over her heart until the anthem concludes. People should not mill around while the anthem plays.
A male should remove his hat (discounting religious headwear such as a yarmulke) with his right hand and hold it over his left shoulder. Thus, the hand holding the hat is placed over the heart.
Eating and Drinking
According to the Emily Post Institute, a citizen should not eat, drink, smoke or chew gum during the national anthem. If possible, she should set down her food containers so that there are no items in her hands.
Individuals in military uniform must face the flag, and upon the first note of the anthem, perform the military salute. This position should be held throughout the entire anthem.
Although U.S. Code § 301 provides a guide for national anthem etiquette, it is not considered a law under which a person may be prosecuted if he chooses not to follow the protocol. The First Amendment of the U.S. Constitution protects the rights of those who do not follow this protocol for personal reasons. For example, it is against religious practice for Jehovah's Witnesses to stand during the playing of any country's national anthem.
Anthems of Other Countries
It is common for other countries' national anthems to be played in the United States, especially during sporting events when participants represent different countries (e.g., the Olympics). During the playing of another country's anthem, the National Flag Foundation states that U.S. citizens should face the guest country's flag and stand at attention. Civilian males should remove their hats.