-When a gentleman “dons” his hat to leave or “doffs” his hat to a lady, his actions are being described by two British colloquialisms that come from contractions of the phrases “do on” meaning “to do”, and the Middle English “doffen”, which became “don off” meaning “to do off”!
-Hats are tipped, (or doffed) slightly lifting the hat off your forehead, when meeting a lady (remove your hat if you stop to talk), or to "say" to anyone, male or female – thank you, excuse me, hello, goodbye, you’re welcome or how do you do.
-Tipping of the hat is a conventional gesture of politeness. This hat tipping custom has the same origin as military saluting, which came from the raising of medieval Knights face visors to show friendliness.
-Hats are worn less now, but at the turn of the 20thcentury, all adults wore hats whenever they left the house. It was a matter of good personal hygiene, since hats were a protection from industrial dirt.
-Hats are removed when inside, except for places that are akin to public streets, like lobbies, corridors, and crowded elevators (non-residential). In a public building (where there are no apartments) the elevator is considered a public area.
-You may choose to remove your hat in a public elevator, but in the presence of a lady your hatmust be removed.
-A gentleman takes off his hat and holds it in his hand when a lady enters the elevator in any building that can be classified as a dwelling such as an apartment house or hotel. He puts it on again in the corridor.
-A public corridor is like the street, but an elevator in a hotel or apartment house has the character of a room in a house and there a gentleman does not keep his hat on in the presence of ladies.
-Hats are removed for the National Anthem, passing of the Flag and funeral processions, outdoor weddings, dedications, and photographs.
-Removed hats are held in hand in such a way that only the outside and never the lining is visible.
via askandyaboutclothes.com