The edge states and optical transition energies in carbon nanoribbons are investigated with density-functional calculations. While the ground state of zigzag ribbons is spin polarized, defects at the edges destroy spin polarization and lead to a nonmagnetic ground state. Scanning tunneling spectroscopy will thus show different features depending on edge quality. Optical transition energies in nanoribbons Eii are strongly affected by the edges and confinement, which introduce a term inversely proportional to their width. After removing that term, the scaling of Eii is quantitatively similar to that in carbon nanotubes.