While other elements are often important, a lot of the chemistry of acids and bases comes down to two elements: oxygen and hydrogen. In this section, we will discuss how bonding between these elements works in the context of acid-base chemistry, particularly discussing the effects of having a metal or a non-metal bonded to oxygen.
At right is the Lewis structure of hypochlorous acid, HOCl. As you can see, oxygen is single-bonded to both a hydrogen atom and a chlorine atom. As an acid, HOCl is a proton donor, meaning it is relatively easy to break the H-O bond, losing H+ and leaving the electron pair behind on oxygen.
What is it about this molecule that makes it prone to losing a proton like this? After all, the H-O bond in water is quite strong and does not easily break apart in this way. A large piece of the puzzle is in the chlorine atom. Because it is quite electronegative, it exerts a fairly strong pull on the electrons in oxygen. The oxygen in turn pulls more on the electrons in its bond with hydrogen, "hogging" them more for itself and weakening that bond.
Compare this with NaOH, which also has hydrogen bonded to oxygen, which is bonded to a third element, in this case sodium, a metal.
However, because sodium is a metal, the nature of this bond is very different. It is ionic, not covalent. Sodium doesn't pull on the electrons in oxygen like chlorine does, meaning they are fully "localized" on the oxygen atom. Put another way: oxygen in NaOH has a lot of electron density. Under the Lewis definition of basicity (bases are electron pair donors) it's relatively easy for the oxygen to reach out an make a new bond to H+, or to some other Lewis acid.
This pattern holds up very well in general; when you have hydrogen and oxygen bonded together with a non-metal element, the compound is usually an acid. When hydrogen and oxygen are bonded (generally as hydroxide) to a metal element, the compound is usually a base.