Nitrogen-doped carbon dots encapsulated in the mesoporous channels of SBA-15 with solid-state fluorescence and excellent stability.