In genetics, two nucleotides on opposite complementary DNA or RNA strands that are connected via hydrogen bonds are called a base pair. As DNA is usually double-stranded, the number of base pairs in the dsDNA strand equals the number of nucleotides in one of the strands. In DNA, adenine and thymine, as well as guanine and cytosine, can be a base pair. In RNA, thymine is replaced by uracil.

The following figure shows the chemical structures of properly base-paired nucleic acids. Water molecules are shown providing hydrogen bonds in the major and minor grooves; in vivo, these positions may occupied by DNA-binding proteins instead of water.

Chemical structure of base pair bonding.
The larger nucleic acids, adenine and guanine, are members of a class of doubly-ringed chemical structures called purines; the smaller nucleic acids, cytosine and thymine (and uracil), are members of a class of singly-ringed chemical structures called pyrimidines. Purines are only complementary with pyrimidines: pyrimidine-pyrimidine pairings are energetically unfavourable because the molecules are too far apart for hydrogen bonding to be established; purine-purine pairings are energetically unfavourable because the molecules are too close, leading to electrostatic repulsion. The only other possible pairings are GT and AC; these pairings are mismatches because the pattern of hydrogen donors and acceptors do not correspond.

Chemical analogs of nucleotides can take the place of proper nucleotides and establish non-canonical base-pairing, leading to errors in DNA replication and RNA transcription. Some analogs are carcinogens; others are chemotherapy drugs.