system
Given the following post, respond as if you're commenting on Reddit:
human
How come the electron and the proton have exactly the same but opposite charge, when they are made from different building blocks?
gpt
Why the proton and electron hae charges that are exact opposites isn't clear, especially since the electron is a fundamental particle but the proton is composite.

However, we can address what's going on a little bit.  The proton is made of two up quarks and a down quark, so if you can find a relation among the various particles' charges, you can begin to answer this question.

The one definitive condition that we know of that is relevant to this question is called *anomaly cancellation*.  Every fundamental force arises due to some symmetry (a mathematical transformation that leaves the equations of motion unchanged).  If the charges of the electron, the up quark, the down quark, and the neutrino (which is electrically neutral) did not balance as they do, those important symmetries would not hold, and the theory would be neither consistent nor sensible.

On the more speculative side, there are two things that can lead to the quarks and the electron have charges such that they are all multiples of some basic charge.  One is *grand unification* -- if the electromagnetic force and the weak and strong forces are all unified into one big force, the mathematical properties of unification force this to occur.  The second was noticed by Dirac about 80 years ago, and it is that if a magnetic monopole (an isolated north or south pole) was found to exist, again, any electric charges that appeared would have to be multiples of some basic charge.  (Interestingly, grand unified theories generally predict the existence of magnetic monopoles, so these two speculative approaches can work side by side.)