U.S. stocks climbed in afternoon trading on Tuesday, lifting both the Dow and S&P 500 to record highs as health care shares extended this week's gains.

Actavis PLC, Gilead Sciences, Celgene and other biotech names were among the S&P 500's biggest drivers, a day after Allergan agreed to be bought by Actavis. The Nasdaq biotech index was up 2.1 percent, adding to Monday's 0.3 percent gain.

The S&P health care index was up 1.6 percent, while shares of Actavis were up 8.3 percent, Gilead's rose 3.3 percent and shares of Celgene were up 2.4 percent. Helping Actavis were bullish analyst notes.