Federal law stipulates many aspects of flag etiquette. The section of law dealing with American Flag etiquette is generally referred to as the Flag Code.
Some general guidelines from the Flag Code answer many of the most common questions:
The Flag Code is voluntary, it includes no penalties or enforcement provisions.
It serves as a guide for civilians who wish to properly honor our beloved flag. It carries no penalties or enforcement procedures.
It does not attempt to anticipate every possible flag display situation. Rather, it provides a guide against which situations not contained within it may be measured.