Investors remained in a buying mood Thursday, driving U.S. stocks broadly higher for the third day in a row.

The latest gains added to the market’s rebound from the brief but steep slump that followed Britain’s vote to leave the European Union a week ago.

While the rally suggests that traders’ anxiety over Britain’s departure from the EU have eased, a surge in U.S. bond prices Thursday signaled many investors remain cautious about the possible long-term implications. As bond prices rose, the yield on the 10-year Treasury note fell to 1.47 percent.

Consumer staples companies posted the biggest gains. Utilities stocks, a traditional safe haven for investors seeking less risk, were a close second. Oil prices fell.

“The equity market has realized that the ‘Brexit’ in a vacuum by itself is not a reason to wholesale abandon equities,” said David Schiegoleit, managing director of investments for the private client reserve at U.S. Bank. “But there is still the fear that it becomes contagious with other economies in Europe.”

The Dow Jones industrial average gained 235.31 points, or 1.3 percent, to 17,929.99. The Standard & Poor’s 500 index rose 28.09 points, or 1.4 percent, to 2,098.86. The Nasdaq composite added 63.43 points, or 1.3 percent, to 4,842.67.

The S&P 500 index added 1.9 percent in the April-June period.

Much of the biggest gains came from energy stocks, which benefited from a rebound in oil prices, and utilities and telecom companies, which became more attractive as bond yields declined. The index is up 2.7 percent so far this year.

The Dow, which gained 1.4 percent during the second quarter, is up 2.9 percent this year. The Nasdaq lost 0.6 percent in the second quarter and is down 3.3 percent through the first half of 2016.

.