Thank you Patriot for sourcing the federal code for recognizing the flag. Just looked it up and found it interesting.
U.S. Code › Title 36 › Subtitle I › Part A › Chapter 3 › § 301 - 36 U.S. Code § 301 - National anthem
(a) Designation.—
The composition consisting of the words and music known as the Star-Spangled Banner is the national anthem.
(b) Conduct During Playing.—During a rendition of the national anthem—
(1) when the flag is displayed—
(A) individuals in uniform should give the military salute at the first note of the anthem and maintain that position until the last note;
(B) members of the Armed Forces and veterans who are present but not in uniform may render the military salute in the manner provided for individuals in uniform; and
(C) all other persons present should face the flag and stand at attention with their right hand over the heart, and men not in uniform, if applicable, should remove their headdress with their right hand and hold it at the left shoulder, the hand being over the heart; and
(2) when the flag is not displayed, all present should face toward the music and act in the same manner they would if the flag were displayed.