A novel strategy for tailoring the adsorption and structural properties of ionic liquid derived carbons has been developed. By changing the carbonization temperature and ratios of ionic liquids (ILs) containing a cross-linkable anion, such as 1-butyl-3-methylimidazolium tricyanomethanide [BMIm][C(CN)(3)] and 1-ethyl-3-methylimidazolium tetracyanoborate [EMIm][B(CN)(4)], boron and nitrogen-rich carbons with slit-like pores and specific surface areas exceeding 500 m(2) g(-1) have been prepared. Furthermore, the nitrogen-rich carbons exhibit high adsorption capacity for CO(2) adsorption and selectivity for CO(2)/N(2) separation.