The British government has said it will ban the sale of new petrol, diesel and hybrid cars by 2040 as part of an effort to curb pollution.