CO2 gas sensing is of great importance because of the impact of CO2 on global climate change. Here, utilizing an inverse opal hydrogel, we describe a CO2 gas sensing method that allows highly sensitive and selective detection over a wide concentration range. The CO2 sensor is specific, quantitative, interference tolerant and without the need for special instruments.