The electronic and optical properties, including band structure, density of states (DOS), absorption rate, refractive index, and dielectric function, of anatase TiO2 codoped with N and first transition elements are investigated using the plane wave pseudopotential method based on the density functional theory. The calculation results show that TiO2 codoping with N and first transition elements (Sc, V, Cr, Mn, and Fe) lead to significant reduction of conduction band relative to the Fermi level, reduction of band gap width, formation of new donor, and acceptor impurity levels below the conduction band and above the valence band, and cause some redshifts of optical absorption band edge with the amount of redshift decrease in the following order: N-Fe 〉 N-Cr 〉 N-Mn. Further, the synergistic effect of shallow donor and acceptor levels enhances light excitation for effective separation of electron-hole pairs and enhancement of light absorption ability, thereby increasing the TiO~ photocatalytic properties. This study reveals that the visible-light absorption ability of the codoped anatase TiO2 decreases in the order of N Fe 〉 N Cr 〉 N-Mn 〉 N-Sc 〉 N-V 〉 N, and does not monotonically follow the dopant atomic number. Especially, in N-Cr codoped TiO2, the 4s atomic orbit of Cr is not completely filled, which hybridized with the p electronic orbit most probably acts as photo-generated electron trap centers resulting in higher photocatalytie activity than that of N-Mn codoped TiO2.