The S&P 500 headed for its best December in nearly two decades as U.S. stocks advanced in thin trade on Wednesday, lifted by investor optimism about the economy in 2011.

The Dow Jones industrial average <.DJI> gained 9.84 points, or 0.09 percent, to 11,585.38, according to the latest available figures. The Standard & Poor's 500 Index <.SPX> gained 1.29 points, or 0.10 percent, to 1,259.80. The Nasdaq Composite Index <.IXIC> gained 4.05 points, or 0.15 percent, to 2,666.93.

(Reporting by Edward Krudy; Editing by Kenneth Barry)