Optical and mechanical properties of diamond-like carbon films grown by chemical vapor deposition were investigated as a function of the nitrogen content in the gas mixture. The nonmonotonic variation of the optical band gap and the microhardness of the films are interpreted using a model which allows for the influence of nitrogen on their structure. It is shown that nitrogen-containing diamond-like carbon films hold out promise as protective and antireflection coatings for silicon solar cells.