Two protons in an atomic nucleus repel each other, but they are also attracted to each other. Explain.

Well, the electrostatic force is pushing them apart but when they are very close as in a nucleus the nuclear or "strong" force is attractive and holds them together.

The repulsion between two protons in an atomic nucleus is due to their like electrical charges. Protons carry a positive charge, and according to the principles of electrostatics, like charges repel each other. This repulsion is a fundamental force known as the electrostatic force.

However, in spite of this repulsion, protons are still attracted to each other. This attraction is the result of a different fundamental force known as the strong nuclear force or nuclear binding force. The strong nuclear force acts between all nucleons (protons and neutrons) in the nucleus and is responsible for holding them together.

The strong nuclear force is independent of electric charge and acts at a very short range – only within the nucleus itself. It is one of the four fundamental forces of nature, along with gravity, electromagnetism, and the weak nuclear force.

The strong nuclear force is stronger than the electromagnetic repulsion between protons. At an extremely short range, it overcomes the electrostatic repulsion and binds the protons together. This force is also responsible for holding the nucleus together as a whole. The number of protons and neutrons in the nucleus, as well as their arrangement, determine the stability of the nucleus and the type of element it forms.

In summary, while protons in an atomic nucleus repel each other due to their like electrical charges, they are also attracted to each other by the strong nuclear force, leading to the stability of atomic nuclei.