I was answering an unrelated question about solubility of some heterocycles. While that was an interesting question, the pKa of the compounds were actually more interesting and got me thinking about this again. The key is the stereoelectronic effects. Which protons are aligned with the pi-system?
For example, with the following enolization, the product is resonance stabilized. However, there is a stereoelectronic effect associated with the deportation In the diagram below, note how the sigma C-H bond is aligned with the pi-bond of the carbonyl group. That is the hydrogen most easily removed. Also see: http://www2.chem.ubc.ca/courseware/330/13Oct05.pdf
Logically, if resonance increases the acidity of a hydrogen atom, then the electrons of the sigma bond being deprotonated should be the electrons that become part of the pi-resonance system. For an OH bond, I cannot determine if the C-O bond should rotate so the O-H bond can overlap with the pi-system. Even rotation of the bond of an amide cannot be ruled out even though IR and NMR support non-bonded electron resonance with a C=O. However, there are numerous cyclic systems in which the bond angles are more limited in their orientation and they still show considerable acidity.
I argue that all else being equal, the electrons of the N-H bond are not participating in any resonance forms. In several of the compounds pictured above, the electrons of the anions do not participate in the resonance structures of the anions. The anion electrons are orthogonal to the resonating electrons. Since that is true, then the formation of a resonance stabilized anion does not seem necessary to explain the greater acidity of a carboxylic acid. That is, even though the non-bonded electrons of a carboxylate can be shown in two different resonance forms, the increase in acidity is not the result of their participation.
What anyone who might be analyzing these structures could recognize is how an sp2 or sp-hybridized atom possesses a greater degree of electron withdrawing character than might have been expected from their sp3-hybridized counterparts. If additional electron withdrawing atoms are also present, the acidity can further increase.
Also note, resonance is occurring in these examples. I have chosen to illustrate the nitrogen atom acidities because they can be stereoelectronically constrained. Even though we may write resonance structures for the starting materials or the conjugate acids, the electrons of the former N-H bond are not participating.
Another poster compared a peracid to a carboxylic acid for resonance stabilization. The poster commented that peroxyacetic acid had a higher pKa because it was not stabilized by resonance and provided the following data:
Peroxyacetic acid pKa 8.2 1.10A
Acetic acid pKa 4.8 0.97A
I find this data in accord with what one should expect for an inductive effect. For example, hypochlorous acid (HOCl) has a pKa of 7.5 and hydrogen peroxide, also not resonance stabilized, has a pKa of 11.6. These pKa’s are in the range of peroxyacetic acid and could have been expected. I would characterize an acetate as a weaker electron withdrawing group than chloride. The poster also stated that the acidity was reduced in peracetic acid because it was not resonance stabilized. Although I agree that peracetic acid is not resonance stabilized, I disagree that resonance is why acetic acid is a stronger acid. Note the pKa for pyrrole, 17.5. Even though a pair of non-bonded electrons are present on the nitrogen atom, the newly formed electrons of the anion are not participating in the resonance structure. The anion electrons are orthogonal to the pi-electrons, yet the pKa is much lower than a simple amine (~35).
The poster made a second point about bond length and bond strength. Bond strength arguments are frequently made in a rather casual manner. If you were to find bond strength data, it refers to homolytic bond strength. If homolytic bond data were used, then a completely different and incorrect prediction of acidities would result. Acidity is a heterolytic bond cleavage. Secondly, the bond length data does agree with heterolytic bond strengths. Here is why. If you compare the bond lengths of CH4, NH3, H2O, and HF, HF has the shortest bond. It also is the most acidic. The key to understanding acidity is the proton-electron pair distance. We cannot measure that directly, but if the inverse square law applies (and it does), then the greater the proton-electron pair distance, the weaker the bond. Therefore, we know as the electrons are pulled closer to the nucleus, they are pulled away from the proton resulting in a weaker bond. Additionally, the bond length tells us the distance between the proton and oxygen nucleus in this case. The charges of both are the same, therefore the closer the proton is to the nucleus, the greater the repelling force. This repelling force is complimentary an increased proton-electron pair distance and results in the increase in acidity.