"Contempt" is the failure or refusal to obey a court order. Court orders do not mean much if they cannot be backed by force. To take the most extreme example in U.S. history: in September 1957, the school district in Little Rock, Arkansas was ordered by a federal judge to desegregate Central High School by allowing nine black students to attend. The Governor of the state, Orval Faubus, expressed contempt for the judge's ruling by calling out the state National Guard to prevent the students from attending the school. When Governor Faubus failed to restore order and enforce the order, President Eisenhower dispatched the 101st Airbone Division to Little Rock.
Mostly, the mere threat of force is sufficient, but when a reminder is necessary, courts have contempt powers: the power to call upon the executive to restrain an individual.
Direct and Indirect Contempt
Direct contempt is contemptuous conduct in the immmediate presence of the judge. Lawyers are frequently the perpetrators of this kind of contempt, because lawyers, unlike the rest of us, have to spend a lot of time in front of judges. Direct contempt can be punished summarily. Thus, if I were to lose my temper and tell a judge to take his ruling and put it where the sun does not shine, the judge may instantly rule that I should spend a day or so in jail, and direct the bailiff to arrest and remove me from the court's presence. Judges have broad discretion in dealing with instances of direct contempt: an appellate court is likely to defer to the judge's decision about an act performed in his presence.
Indirect contempt is the failure to obey a court order, usually outside the direct presence of the judge. An example is failure to pay child support. Indirect contempt cannot instantly be punished. The court must require a hearing, and allow the "contemnor" a chance to prove any defenses (excuses). With the child support example, the defense might be that the contemnor has no money. Since being broke is not a willful failure to pay, there is no contempt for the court's order.
Civil and Criminal Contempt
The difference between civil and criminal contempt is purpose, and thus the conditions of release. Criminal contempt is punitive. The contemnor is sentenced to imprisonment for a definite term, to punish a specific instance of deliberate, intentional disobedience, following a trial and proof beyond a reasonable doubt.
Civil contempt, on the other hand, is remedial. The purpose is to coerce defendant to perform the act ordered by the court. Imprisonment for civil contempt is ordered where a contemnor has refused to do an affirmative act required by the provision of a mandatory order (such as an order by the court to answer certain questions). Imprisonment in such cases is not inflicted as punishment, but instead is intended to coerce a defendant to comply (e.g. answer the questions). No definite term of imprisonment is set, rather, the term lasts as long as the contemnor refuses to obey. Since the contemnor can secure his release at any time by compliance, he is said to "carry the keys of his prison in his own pocket.".