Technology companies led U.S. stocks solidly higher Tuesday, giving the market its second straight gain.
Consumer services companies, retailers and healthcare stocks accounted for a big slice of the broad rally. Banks declined, and oil prices recovered from an early slide.
Strong company earnings and outlooks, as well as some encouraging economic data, helped put investors in a buying mood.
"Even though we're early in the earnings season, the fact that we continue to see good earnings and earnings growth come out is really what's driving the market," said Nana Adae, global investment specialist at J.P. Morgan Private Bank. "Earnings growth ties to fundamentals, and fundamentals are key."
The Standard & Poor's 500 index climbed 28.55 points, or 1.1%, to 2,706.39. The Dow Jones industrial average rose 213.59 points, or 0.9%, to 24,786.63. The latest gain nudged the blue-chip average into positive territory for the year.
The Nasdaq composite jumped 124.81 points, or 1.7%, to 7,281.10. The Russell 2000 index of smaller-company stocks climbed 16.77 points, or 1.1%, to 1,579.80.
The market has been preoccupied lately with concerns over geopolitical and trade tensions, but Wall Street has something else to focus on over the next few weeks: company earnings.
Financial analysts are forecasting the strongest growth in seven years for S&P 500 companies, partly because of a resurgent global economy, but also because of expectations of how last year's corporate tax cut will affect corporate balance sheets.
"There's no doubt that corporate tax reform is a tail wind for earnings, but organic growth is really what is driving a lot of these earnings," Adae said.
Netflix shares jumped 9.2% to $336.06 after the video streaming service said it gained 7.4 million subscribers in the first quarter, more than analysts expected. Other technology companies also posted gains. Microsoft rose 2% to $96.07. Amazon.com climbed 4.3% to $1,503.83.
Twitter leaped 11.4% to $31.84 after Morgan Stanley analysts upgraded their rating of the stock.
Roku climbed 9% to $35.98 after announcing that the ESPN+ streaming service would be available through its devices.
UnitedHealth Group shares rose 3.6% to $238.55 after the nation's largest health insurer reported a 31% jump in first-quarter profit and said it gained Medicare Advantage and Medicaid customers. It also raised its forecast for 2018.
Celanese rose 3.7% to $110.38 after the chemical company's latest results beat analysts' estimates. The company also raised its annual forecasts.
Some companies failed to impress traders. Johnson & Johnson fell 0.9% to $130.54 after much-higher spending and one-time charges offset a big jump in the company's first-quarter revenue.
Tesla slid 1.2% to $287.69 after reports that the automaker shut down production of its Model 3 mass-market electric car again to solve manufacturing bottlenecks.
Southwest Airlines fell 1.1% to $54.27 after one person was killed and others were injured aboard one of the airline's jets. The plane made an emergency landing at Philadelphia's airport Tuesday after an engine failure.
Investors also got some encouraging economic data Tuesday.
The International Monetary Fund upgraded its economic outlook for the United States in 2018, forecasting that the U.S. economy will grow 2.9% this year, up from the 2.7% it forecast in January and from the 2.3% growth the economy achieved last year. And the Federal Reserve said U.S. factory output rose slightly last month.
The Commerce Department said that housing starts rose in March to a seasonally adjusted annual rate of 1.32 million. That helped send home builder stocks higher. Hovnanian Enterprises led the pack, climbing 4.7% to $2.02.
Bond prices rose. The yield on the 10-year Treasury slipped to 2.82% from 2.83%. The decline in bond yields, which influence interest rates on mortgages and other loans, weighed on some bank stocks. Comerica shares fell 3.5% to $92.74. SunTrust Banks fell 2.2% to $65.95.
The dollar fell to 107.02 yen from 107.10 yen. The euro fell to $1.2367 from $1.2381.
Gold fell $1.20 to $1,349.50 an ounce. Silver rose 11 cents to $16.79 an ounce. Copper fell 2 cents to $3.08 a pound.
Benchmark U.S. crude rose 30 cents to $66.52 a barrel. Brent crude, used to price international oils, rose 16 cents to $71.58 a barrel. Heating oil fell 1 cent to $2.06 a gallon. Wholesale gasoline was flat at $2.04 a gallon. Natural gas fell 1 cent to $2.74 per 1,000 cubic feet.
Major indexes in Europe advanced. Germany's DAX climbed 1.6%, France's CAC 40 rose 0.8%, and Britain's FTSE 100 gained 0.4%.
In Asia, Japan's benchmark Nikkei 225 edged up 0.1%, while South Korea's Kospi lost 0.2%. Hong Kong's Hang Seng shed 0.8% after new data showed China's economic growth held steady in the first quarter. Australia's S&P/ASX 200 was unchanged.
2:35 p.m.: This article was updated with closing prices, context and analyst comment.