Understanding the general mechanisms of sequence specific DNA recognition by proteins is a major challenge in structural biology. The existence of a 'DNA recognition code' for proteins, by which certain amino acid residues on a protein surface confer specificity for certain DNA bases, has been the subject of much discussion. However, no simple code has yet been established. The principles of DNA recognition can be described at two levels. The 'chemical' rules describe the partnerships between amino acid side chains and DNA bases making favourable interactions in the major groove of DNA. Here I analyze the occurrence of nucleotide-amino acid contacts in previously determined crystal structures of DNA-protein complexes and find that simple rules pertain. I also describe 'stereochemical' rules for the probe helix type of DNA-binding motif found in certain transcription factors including leucine zipper and homeodomain proteins. These are a consequence of the binding geometry, and specify the amino acid and base positions used for the contacts, and the sizes of residues in the contact interface. The chemical rules can be generalized for any DNA-binding motif, while the stereochemical rules are specific to a particular DNA-binding motif. The recognition code for a particular binding motif can be described by combining the two sets of rules.