The pure and Yb-doped 3D ordered porous SnO2 with a controllable pore diameter (around 50 nm, 800 nm, and 1200 nm) were prepared by a simple template method. 3 at% Yb-doped 51.3 nm ordered porous SnO2 (51.3 nm SnO2/3%Yb) showed the largest specific surface area (70.08 m(2)/g) and the biggest oxygen vacancy in nitrogen adsorption-desorption and XPS analysis. The response of 51.3 nm SnO2/3%Yb is 95 against 50 ppm HCHO at 108 degrees C, which is 3.7 times higher than 1228.0 nm SnO2/3%Yb (27), 2.1 times higher than 806.0 nm SnO2/3%Yb (45), and 2.4 times higher pure 57.3 nm SnO2(40). However, the response of pure 57.3 nm SnO2 (40) is only 2.9 times higher than pure 1231.0 nm SnO2(13.5), and 1.2 times higher than pure 832.1.0 nm SnO2 (30). Especially, the detectable formaldehyde (HCHO) of 51.3 nm SnO2/3%Yb minimum limit has been reduced to 50 ppb and the relevant response is 3.5. Besides, 51.3 nm SnO2/3%Yb also exhibited high linearity (50 ppb-200 ppm), the fast response time (2 s) and excellent selectivity toward HCHO. Above all, for the same kinds of SnO2 nanomaterials, the smaller pore size is, the stronger sensitivity it will be, and under the effect of Yb doping, the gas sensitivity is enhanced more significantly with the decrease of the pore size. Besides, for the same kinds of SnO2 nanomaterials that have the same pore size, the gas-sensitive property is also significantly enhanced due to the doping of Yb.