The flapping dynamics of vertically clamped three-dimensional flags in a Poiseuille flow was studied numerically by using the immersed boundary method. First, the flapping dynamics of a single flag was explored for comparison. Two distinct flow modes were observed: a flapping mode and a deflected mode. In the flapping mode, periodic vortices shed from the flag are formed, leading to alternating upstroke and downstroke flapping motions induced by the hydrodynamic and restoring forces. In the deflected mode, the flag is initially deflected by the hydrodynamic force and reaches a stationary state; the hydrodynamic force is balanced by the restoring force. For tandem flags, when the gap distance is small, the flags behave as one single flag with a higher bending rigidity. When the gap distance is intermediate, the front flag deflects the oncoming flow away from the rear flag. The flapping motion of the front flag is significantly confined by the presence of the rear flag, which results in an attenuation of more than 50% in its flapping amplitude. When the distance is large, the impact of the rear flag on the upstream flow field is negligible, so the front flag exhibits a flapping amplitude and frequency that are similar to those of a single flag. The vortices shed from the front flag induce the formation downstream of a low pressure region, which results in active flapping in the rear flag with a strong amplitude. There are two vortices shed from the tandem flags in each flapping period. When they are far apart, the phase difference is linearly dependent on the gap distance.