Nucleotides in DNA and RNA are linked by phosphodiester bonds, where the phosphate group of one nucleotide bonds to the sugar of the next nucleotide, forming the backbone of the nucleic acid chain. This linkage allows the formation of long polymer chains.