The nucleic acids Deoxyribonucleic Acid (DNA) and Ribonucleic Acid (RNA) are composed of units called nucleotides which consist of three subunits sugars (deoxyribose and ribose), phosphates and nitrogenous bases (adenine, thymine, guanine, cytosine, and uracil).
The sugars like all sugars are composed of carbon, hydrogen, and oxygen. The phosphates are made from phosphorus and oxygen, and the bases are composed of nitrogen, carbon, hydrogen, and oxygen. Hydrogen bonds hold the two strands of the DNA double helix together.
This means that the primary elements found in DNA and RNA are Carbon, Hydrogen, Oxygen, Nitrogen, and Phosphorus.
I hope this was helpful.