What is capital gains tax and when does it apply?

What is capital gains tax and when does it apply?