When you look at some molecules you might say “Those atoms are not connected, how are they molecules?”. Because of ionic bonding. In ionic bonding, the atoms are not connected by a pair of electrons like in covalent bonding, they are connected by magnetic forces. One of the atoms are negatively charged, the other is positively charged. It doesn’t have to be single atoms too, they can be two different charged structures as well.
For example, let’s take table salt, NaCl. The sodium and chlorine atoms are not bonded covalently, they are bonded ionically. That means that one of the atoms (sodium) is positively charged, the other (chlorine) is negatively charged. That happens because chlorine is a nonmetal, so it has a tendency to gain electrons. On the other hand, sodium is a metal, and metals have a tendency to lose electrons. So, the chlorine rips off an electron from the sodium, creating an ionic bond. And so they are pulled together by magnetic forces.
In an atom, one of the atoms have to be metal, the other has to be nonmetal. That is because, as I just said, nonmetals have a tendency to gain electrons while metals have a tendency to lose electrons. And just like the sodium and the chlorine, the nonmetal rips an electron off of the metal. (It doesn’t have to rip an electron off. Two pre-charged atoms could form an ionic bond when introduced to each other.
To sum up, there is a metal cation and a nonmetal anion in an ionic bond, and they are pulled together by magnetic forces.