Near-edge x-ray absorption fine structure spectra have been calculated for different carbon-nitrogen molecules, clusters and solids. The compounds investigated are used to model the chemical bonding in carbon nitride thin films. The molecular and cluster spectra are calculated employing the static exchange ab initio technique, while the solid state calculations are performed with the density functional full potential augmented plane wave method.