Nebular emission from star-forming galaxies