U.S. stocks rose on Tuesday after encouraging earnings from healthcare and materials companies and unexpected strength in housing, but weakness in technology and banks tempered gains.

Johnson & Johnson rose 2.4 percent and was the top percentage gainer on the Dow after it reported a first-quarter profit that beat expectations, fueled by higher prescription drug sales and stabilizing performance of its consumer products business.

Offsetting that was Goldman Sachs Group Inc , which fell 2 percent to $150.68 after posting a steep profit drop as trading revenue fell. The investment bank also warned that there were fewer opportunities to make money in the current environment.

Texas Instruments Inc late Monday warned of slower-than-usual quarterly sales growth. The chipmaker's stock was down 0.2 percent, off its lows of the session. Seagate Technology Plc fell 3.4 percent to $17.23 after giving a weak outlook and announcing a $1.4 billion acquisition.

Unless the performance of financials and tech stocks improve, then I think the market could be in store for a correction, said Marshall Front, chairman and chief investment officer at Front Barnett Associates in Chicago.

These are important groups that point toward future economic activity, he said, adding that bank results have by and large been disappointing..

In its earnings report last week, JPMorgan Chase & Co said its book of consumer loans shrank by 10 percent in the quarter, and loans to corporate customers did not grow enough to make up for it.

The Dow Jones industrial average <.DJI> was up 51.81 points, or 0.42 percent, at 12,253.40. The Standard & Poor's 500 Index <.SPX> was up 5.42 points, or 0.42 percent, at 1,310.56. The Nasdaq Composite Index <.IXIC> was up 5.54 points, or 0.20 percent, at 2,740.92.

Materials companies were the top percentage gainers on the S&P. Steel Dynamics forecast strong growth, lifting other steelmakers. The stock rose 4.8 percent to $18.30 while the Dow Jones U.S. steel sector <.DJUSST> climbed 2.6 percent. The S&P materials index <.GSPM> rose 2.6 percent.

Homebuilders also rose after government data showed U.S. housing starts and permits for future home construction rose more than expected in March.

The Dow Jones U.S. home construction index <.DJUSHB> rose 1.4 percent. PulteGroup

rose 3.2 percent to $8.09 and KB Home added 1 percent to $11.41.

Companies scheduled to report quarterly results later on Tuesday include Intel Corp , International Business Machines Corp and Yahoo Inc .

(Editing by Kenneth Barry)