Finance Brain
CoursesBlog
Sign in

Photo by Tyler Prahm on Unsplash

How is capital gains tax worked out on shares you sell?

by financebrain · October 20, 2026

When you sell shares for more than you paid, the profit is a capital gain, and that gain is what gets taxed. The calculation is the sale price minus your cost basis: what you paid, adjusted for things like commissions and stock splits.

How much tax you pay on that gain depends mostly on one thing: how long you held the shares. Held for one year or less, the gain is short-term and taxed as ordinary income, at the same rate as your wages. Held for more than a year, it's long-term and taxed at lower rates of 0%, 15% or 20%, depending on your taxable income.

Nothing is taxed until you sell

A share that has gone up in value but that you still own creates no tax bill. The gain only becomes taxable when it's realized, meaning when you sell. That gives you some control over timing: when you sell, and in which tax year.

A worked example

Say you bought 100 shares at $20 each. Your cost basis is $2,000. Later you sell all 100 at $50, for $5,000.

  • Gain: $5,000 - $2,000 = $3,000.
  • If you held them a year or less: the $3,000 is taxed as ordinary income. In a 22% bracket, that's $660.
  • If you held them more than a year: at the 15% long-term rate, that's $450.

Same shares, same profit, $210 difference, just from the holding period. On bigger gains the gap gets bigger.

Counting the year correctly

The holding period starts the day after you buy and ends on the day you sell. Shares bought on January 1 reach "more than one year" on January 2 of the following year, not January 1. Selling one day too early turns a long-term gain into a short-term one.

What losses do

If you sell shares for less than your cost basis, you have a capital loss, and losses reduce your taxable gains dollar for dollar. Short-term losses are matched against short-term gains first, and long-term against long-term, before either spills over into the other.

If your losses are bigger than your gains for the year, up to $3,000 of the net loss can be set against your ordinary income, and anything left over carries forward to future years with no expiry date.

Keep your records

You're responsible for reporting the right cost basis, even when your brokerage doesn't track it for you. This gets complicated when dividends have been reinvested for years, because each reinvestment is a new purchase with its own basis and its own holding period.

Higher earners pay a little more

Above certain income levels, an extra 3.8% Net Investment Income Tax applies on top of the capital gains rate. The income thresholds for each rate change, so check the IRS's current figures before planning a sale. State income tax may apply as well.

Learn it properly

Finance Brain's Capital Gains Tax lesson, in the Capital Gains and Investment Taxation course, covers the full netting rules, how inherited and gifted shares are treated, and how the Net Investment Income Tax is worked out. It ends with a short quiz.

Finance Brain is educational content, not financial or tax advice. This post describes US federal rules.