It’s not just polite. It’s a federal law. The Flag Code was officially enacted by Congress in 1942. There are no civil penalties for improper display but if you're going to learn the rules, there's no better day than the Fourth of July.
Below is everything you need to know about proper flag etiquette. For more tips and history, The American Legion's resident "Flag Guru" Mike Buss offers these tips. You can find full audio by clicking "Listen Now" in the upper left.
1. Light the flag at night
It is the universal custom to display the flag only from sunrise to sunset on buildings and on stationary flag staffs in the open. However, when a patriotic effect is desired, the flag may be displayed 24 hours a day if properly illuminated during the hours of darkness.
2. Marching? Keep it right.
The flag, when carried in a procession with another flag or flags, should be either on the marching right — that is, the flag's own right — or, if there is a line of other flags, in front of the center of that line.
3. All flags are not created equal
No other flag or pennant should be placed above or, if on the same level, to the right of the flag of the United States of America, except during church services conducted by naval chaplains at sea, when the church pennant may be flown above the flag during church services for the personnel of the Navy.
When flags of two or more nations are displayed, they are to be flown from separate staffs of the same height. The flags should be of approximately equal size. International usage forbids the display of the flag of one nation above that of another nation in time of peace.
4. When a flag is hoisted, you should ...
During the ceremony of hoisting or lowering the flag or when the flag is passing in a parade or in review, those present in uniform should render the military salute. Members of the Armed Forces and veterans who are present but not in uniform may render the military salute. All other persons present should face the flag and stand at attention with their right hand over the heart, or if applicable, remove their headdress with their right hand and hold it at the left shoulder, the hand being over the heart. Citizens of other countries should stand at attention. All such conduct toward the flag in a moving column should be rendered at the moment the flag passes.
5. Don't wear it
The flag should never be displayed with the union down, except as a signal of dire distress in instances of extreme danger to life or property.
The flag should never touch anything beneath it, such as the ground, the floor, water, or merchandise.
The flag should never be carried flat or horizontally, but always aloft and free.
The flag should never be used as wearing apparel, bedding, or drapery. It should never be festooned, drawn back, nor up, in folds, but always allowed to fall free.
6. Show some respect
No disrespect should be shown to the flag of the United States of America; the flag should not be dipped to any person or thing. Regimental colors, state flags and organization or institutional flags are to be dipped as a mark of honor.
Bonus: here's a handy GIF showing how to properly fold an American Flag: