Maybe this has been asked already: would be acceptable to give a reference to a math.stackexchange or MathOverflow answer in a paper intended for publication?
I think that depends on the purpose of the reference.
If the purpose is to acknowledge the origin of an idea you use and the idea seems to have been invented by a MSE/MO contributor in an answer, then referencing that origin is certainly apropriate:
Theorem. Such-and-such holds.
Proof. Bla bla bla. QED.
(The idea behind the preceding proof of the well-known such-and-such property seems first to have been discovered by an anonymous user on the website math.stackexchange.com; see [link]).
Depending on the editorial policies of the publication venue, you may or may not be able to use the ordinary citation/note apparatus for such crediting, but surely giving credit in some form is appropriate.
On the other hand, if you want to cite MSE/MO as an authority for the truth of a claim, then you're on thinner ice. You won't get away with writing
... and therefore this and that. Since such-and-such always holds (see math.stackexchange.com/questions/1234567/is-such-and-such-always-true), we conclude that every equivalence class of glurbnyxes is finite, which completes the proof of Theorem 1.
Part of the problem here is that MO and MSE posts are not peer-reviewed (in the formal sense usually spoken about for scientific publications), but in more pragmatic terms the trouble is that a reader of that sentence needs to go outside of your paper in order to make any assessment about whether to believe such-and-such or not -- it's not as with an established journal, where a reader has the option of thinking "well, if XYZ journal accepted it, then I'll tentatively assume that it is true". Also note the risk that the question may have been deleted from MSE (or SE, Inc. have gone bankrupt or decided to shut down the site or whatever) by the time somebody wants to check your work.
Instead, you need to reproduce the argument you saw here.