Energy and food costs continue to rise quickly, but the prices of other items are being restrained by a faltering economy that is helping keep overall inflation in check.

The Labor Department Friday said the consumer price index rose 0.8% in May and was up 4.2% from a year ago, reflecting surging energy, food and transportation costs.

But...