Here's why:
* Sodium (Na) is a metal and has one electron in its outer shell. It readily loses this electron to achieve a stable electron configuration.
* Chlorine (Cl) is a nonmetal and has seven electrons in its outer shell. It readily gains one electron to achieve a stable electron configuration.
When sodium and chlorine react, sodium loses its electron, becoming a positively charged ion (Na+). Chlorine gains that electron, becoming a negatively charged ion (Cl-). These oppositely charged ions are attracted to each other by electrostatic forces, forming a strong ionic bond.
This attraction between the positive sodium ions and negative chloride ions creates a crystal lattice structure, which is what makes table salt a solid.