A code of honor is a set of principles that an individual follows at all times. Individual codes differ, but they all require "honorable" behavior by a standard set by the code. It usually involves the willingness to risk death rather than being considered dishonorable. This is because codes of honor usually, though not always, develop in cultures where the force of law is not present, whether it be because the culture has no main government, such as a nomadic people; the main government is distant and cannot influence things, such as the Old West; the government cannot be involved, such as among criminals, or the law effectively does not apply to the people in question, such as among those in the upper class of many periods.

There are, and have been, many different forms of such a code. Chivalry had its set of norms knights had to follow; later, a watered-down version of those ideals was considered proper for a gentleman. In the Far East, samurai had bushido. Pirates and brigands might or might not have some sort of honor code -- sometimes, there is honor among thieves, particularly among some of the Tong gangs. Many of these senses of what is honorable are sexist and based in a male-dominated view, but not all of them are; and someone with a personal code of honor might have some surprising ideas about what is honorable!

There are, however, some common themes in a code of honor. One must often retaliate strongly (often by a duel) against insults or challenges, though the enveloped groups often change; usually, against oneself and those one is close to, and occasionally the culture/nation to which one belongs. Sometimes this extends to protecting certain groups, often those considered unable to protect themselves. Another commonality is that, honor often involves not breaking one's word. Sometimes honor demands equal circumstances when fighting; in chivalry, this extended even to open war. A certain amount of politeness is sometimes expected directly or implied by a given code of honor, as well.