The correlation of the electronic band structure with the photocatalytic activity of AgTaO3 has been studied by simulation and experiments. Doping wide band gap oxide semiconductors usually introduces discrete mid-gap states, which extends the light absorption but has limited benefit for photocatalytic activity. Density functional theory (DFT) calculations show that compensated co-doping in AgTaO3 can overcome this problem by increasing the light absorption and simultaneously improving the charge carrier mobility. N/H and N/F co-doping can delocalize the discrete mid-gap states created by sole N doping in AgTaO3, which increases the band curvature and the electron-to-hole effective mass ratio. In particular, N/F co-doping creates a continuum of states that extend the valence band of AgTaO3. N/F co-doping thus improves the light absorption without creating the mid-gap states, maintaining the necessary redox potentials for water splitting and preventing from charge carrier trapping. The experimental results have confirmed that the N/F-codoped AgTaO3 exhibits a red-shift of the absorption edge in comparison with the undoped AgTaO3, leading to remarkable enhancement of photocatalytic activity toward hydrogen generation from water.