Step 1: Recall the concept of molar volume at STP
At standard temperature and pressure (STP), one mole of any ideal gas occupies 22.4 L. The density of a gas is given by:
\[
\text{Density} = \frac{\text{Mass}}{\text{Volume}}
\]
Since the volume is constant at STP, the density of a gas depends on its molar mass.
Step 2: Compare the molar masses of the gases
The molar masses of the gases are:
- \( \text{O}_2 \): 32 g/mol,
- \( \text{N}_2 \): 28 g/mol,
- \( \text{CO}_2 \): 44 g/mol,
- \( \text{H}_2 \): 2 g/mol.
The gas with the highest molar mass will have the highest density at STP.
Answer: Therefore, \( \text{CO}_2 \) has the highest molar mass and, thus, the highest density at STP. So, the correct answer is option (3).