Can home improvements be written off?

Can I write off home improvements on my taxes? What are the nuances, and how do they affect capital gains when I sell my house?