The Dow Jones Industrial Average and the S&P 500 rose on Wednesday after inflation jumped, but not by quite as much as investors feared when stripping out volatile food and energy prices.

The 30-stock Dow gained 220.30 points, or 0.6%, to 35,484.97 to close at a new record. The index was lifted by names like Caterpillar and Home Depot. The S&P 500 traded up 0.2% to 4,447.70, also notching an all-time high. The technology-heavy Nasdaq Composite traded over 0.1% lower to 14,765.14.

July’s Consumer Price Index released Wednesday showed prices jumped 5.4% since last year, compared to expectations of 5.3%, according to economists surveyed by Dow Jones. The government said CPI increased 0.5% in July on month-to-month basis.

But investors were concentrating on the core rate of inflation, which could signal inflation will remain tempered and the economy will remain strong. CPI, excluding energy and food prices, rose by 0.3% last month, below the 0.4% increase expected. Core prices still jumped 4.3% on a year-over-year basis.

“It’s encouraging to see the pace moderating a bit month over month supporting the notion that recent price increases are transitory and reopening related,” said Mike Loewengart, managing director of investment strategy at E*TRADE Financial. “So while inflation continues to run hot, it’s likely that investors are already pricing it in.”

Used car prices, which investors have been watching as one sign of out-of-control inflation, rose just 0.2% in July after surging more than 10% in the prior month.

The data “should help assuage investor fears that the Fed is too laid-back about inflation pressures, ” said Seema Shah, chief strategist at Principal Global Investors. “The details of the data release suggest some easing in the reopening and supply-shortage driven boost to prices, and tentatively suggests that inflation may have peaked. Investors in the transitory camp will feel slightly vindicated.”

The inflation reading supported the Federal Reserve’s belief that high price pressures are “transitory” as the economic recovers from the pandemic-triggered recession.

The 10-year Treasury yield dipped amid the inflation report and a strong auction. The decline in rates accelerated after Dallas Fed President Robert Kaplan told CNBC that the Fed should start tapering its bond-buying programs in October.

Oil prices dropped and then recovered after the White House called on OPEC and its allies to increase oil production to support the global recovery from the pandemic.

On Tuesday, the Dow and S&P 500 closed at record highs following the Senate passing the $1 trillion infrastructure bill. The legislation earmarks $550 billion in new spending for areas including transportation and the electric grid. The Nasdaq Composite slid nearly 0.5% on Tuesday, registering its second negative session in the last three.

The march to record highs for stocks comes despite Covid case numbers rising in the U.S. and around the world.

“Widespread vaccine distribution and distancing measures have helped limit the variant’s impact, but we could still see some drag on economic growth as some restrictions are reintroduced and consumers potentially become more cautious,” said Barry Gilbert, asset allocation strategist at LPL Financial. “While we may see an increase in market volatility due to the delta variant, we believe the S&P 500 is still likely to see more gains through the end of the year.”

Become a smarter investor with CNBC Pro
Get stock picks, analyst calls, exclusive interviews and access to CNBC TV. 
Sign up to start a free trial today

— with reporting from CNBC’s Yun Li.