This paper reviews and summarizes the recent first-principles theoretical studies of the structural stability, electronic structure, optical and magnetic properties of nonmetal-doped TiO2. The first section presents a comparison study of the structural stability for X-anion and X-cation doped TiO2 (X=B, C, Si, Ge, N, P, As, Sb, S, Se, Te, F, Cl, Br, and I), which reveals that the sites of nonmetal dopants (i.e., at O sites or at Ti sites) in TiO2 are determined by the growth condition of doped TiO2 and the dopants' electronegativities. The next section reviews the electronic structure, optical absorption and mechanism of the visible-light photocatalytic activity for nonmetal-doped TiO2. The third section summarizes the origin of the spin-polarization and the magnetic coupling character in C-(N-and B-) doped TiO2.