Capital gains tax
Tax charged on the profit made when an asset is sold for more than it cost, calculated on the gain above the cost basis rather than on the sale price.
The taxable amount is the sale proceeds minus the cost basis, and the basis is what you paid plus adjustments such as commissions and reinvested dividends. Track the basis poorly and you overstate the gain and overpay, which is how this most often goes wrong in practice.
Two features shape the bill in the United States. The gain is taxed on realisation, so an investment that has risen is untaxed until it is sold and an unsold position carries a gain whose tax has effectively been deferred. The holding period then decides the rate: held more than a year, it is a long term gain taxed at preferential rates, and held for less it is a short term gain taxed as ordinary income at your marginal tax rate.
The mistake is treating the tax as a reason never to sell. Because the gain is taxed only on realisation, holding usually postpones the bill rather than removing it, and the long term rate is set below the ordinary rate a quick sale attracts. The exception in the United States is an asset still held at death, where the basis may reset for the heirs and the gain built up over a lifetime never faces this tax at all. Losses count in the same system: realising them on purpose is tax loss harvesting, and a realised loss offsets a realised gain directly. All of this applies to a taxable account, since a sheltered account is taxed under its own rules.