Hydrogen bonds form when a Hydrogen atom which has a slightly positive charge is attracted to an Oxygen or Nitrogen that is slightly negative, just like a pair of magnets.
The two strands of DNA that make up the double-helix structure are held together by hydrogen bonds between the DNA bases. This illustration shows the hydrogen bonding between the DNA bases adenine (left) and thymine (right). Hydrogen bonding occurs when a hydrogen atom is bound to a highly electronegative element such as nitrogen, chlorine or oxygen. The electronegative element withdraws charge density from the hydrogen atom making it highly positively charged. The hydrogen then forms intermolecular bonds with other electronegative elements.