Using nonlinear vortex-sheet simulations, we determine the region in parameter space in which a straight flag in a channel-bounded inviscid flow is unstable to flapping motions. We find that for heavier flags, greater confinement increases the size of the region of instability. For lighter flags, confinement has little influence. We then compute the stability boundaries analytically for an infinite flag, and find similar results.For the finite flag we also consider the effect of channel walls on the large-amplitude periodic flapping dynamics. We find that multiple flapping states are possible but rare at a given set of parameters, when periodic flapping occurs. As the channel walls approach the flag, its flapping amplitude decreases roughly in proportion to the near-wall distance, for both symmetric and asymmetric channels. Meanwhile, its dominant flapping frequency and mean number of deflection extrema (or "wavenumber") increase in a nearly stepwise fashion. That is, they remain nearly unchanged over a wide range of channel spacing, but when the channel spacing is decreased below a certain value, they undergo sharp increases corresponding to a higher flapping mode.