The rules of base pairing (or nucleotide pairing) are: A with T: the purine adenine (A) always pairs with the pyrimidine thymine (T) C with G: the pyrimidine cytosine (C) always pairs with the purine guanine (G)
The nucleotides in a base pair are complementary which means their shape allows them to bond together with hydrogen bonds. The A-T pair forms two hydrogen bonds. The C-G pair forms three. The hydrogen bonding between complementary bases holds the two strands of DNA together.