In general, the strength of an acid in an organic compound is directly proportional to the stability of the acid's conjugate base. In other words, an acid that has a more stable conjugate base will be more acidic than an acid that has a less stable conjugate base.
Acidic molecules generally have structural features that allow the anion in the conjugate base to delocalize the charge over a larger space. Delocalization of the negative charge (such that one atom doesn't have to bear the full negative charge) makes the molecule more stable. The most important features that stabilize negative charges include the electronegativity, hybridization, and size of the atom upon which the negative charge is located, the electron-withdrawing effects of neighboring electronegative atoms, and resonance effects.
How atoms affect acid strength
On which atom does the negative charge of the acid's conjugate base rest? A negative charge prefers to rest on electronegative (electron-loving) elements. Therefore, a negative charge is more stable on oxygen than it is on nitrogen; similarly, a negative charge is more stable on nitrogen than it is on carbon. For that reason, alcohols (R—OH) are more acidic than amines (R—NH2), which in turn are more acidic than alkanes (R—CH3), as shown here.
Electronegativity increases as you go up and to the right on the periodic table.
The size of the atom also plays a role in stabilizing the negative charge. Charges prefer to be on larger atoms than on smaller atoms. This preference results from large atoms allowing the negative charge to delocalize over a much larger region of space, instead of being concentrated in a small region (as it would on a small atom). As a rule, atom size trumps electronegativity considerations. So, even though fluorine is a more electronegative atom than iodine, HI is more acidic than HF. The much larger iodine atom allows the negative charge to delocalize over a larger space than does the much smaller fluorine atom, and thus makes hydrogen iodide more acidic. The effect that atom size has on acidity is shown here.
How atom hybridization affects acid strength
The orbital on which the lone-pair anion rests also affects the acidity. Lone-pair anions prefer to reside in orbitals that have more s character than p character, because s orbitals are closer to the atom's nucleus than p orbitals, and the electrons are stabilized by being closer to the nucleus. Orbitals that are sp hybridized have 50 percent s character, orbitals that are sp2 hybridized have 33 percent s character, and orbitals that are sp3 hybridized have 25 percent s character. Therefore, anions prefer to be in orbitals that are sp hybridized over those that are sp2 hybridized orbitals, and they prefer to be in orbitals that are sp2 hybridized over those that are sp3 hybridized. The effect of orbital type on acidity is shown here.
How electronegativity affects acid strength
Electron-withdrawing groups on an acid also stabilize the conjugate base anion by allowing some of the charge on the anion to delocalize to other parts of the molecule. For example, trifluoroethanol (shown here) is more acidic than ethanol.
The highly electronegative fluorine atoms (which are electron pigs) on trifluoroethanol pull electron density away from the anion, taking away some of the negative charge from the oxygen, thereby stabilizing the molecule.
How resonance structures affect acid strength
Acids with conjugate bases that allow the negative charge to be delocalized through resonance are stronger acids than acids whose conjugate bases don't have resonance structures. For example, acetic acid, shown here, is much more acidic than ethanol because the conjugate base anion of acetic acid can delocalize the negative charge through resonance.
Resonance structures are a stabilizing feature of molecules and ions.