Photo: LendingMemo.

A capital gain is what you realize when you sell a capital asset (such as a stock, bond, or real estate) at a profit. Until you actually sell a stock, any appreciation in its value is just a "paper" gain, not a realized one.

You may grimace at the thought of handing over a big chunk of your profit to Uncle Sam. However, long-term investors enjoy a favorable capital gains tax rate that doesn't eat into their gains as much as they might expect.

It's lower than other rates -- usually
Here's the first bit of good news related to the capital gains tax rate: For most of us, the long-term capital gains tax rate is quite low. Long-term gains are those earned on assets that were held longer than a year. In fact, those in the 10% or 15% tax brackets pay nothing in long-term capital gains taxes.

Granted, you're likely in a higher tax bracket than that. Most of us face a 15% capital gains tax rate, while those in the top bracket pay 20%. Single filers who earn more than $200,000 and joint filers who earn more than $250,000 also get hit with a 3.8% surtax.

For short-term gains (on assets held for a year or less), the capital gains tax rate is your ordinary income tax rate, which could be 33% to 40% if you're a high earner. (For most of us, it will be 25% or 28%.) Thus there's an incentive to hold on to stocks for at least a year and a day.

Still, even when your capital gains tax rate is a relatively low 15%, it is a tax you will likely have to face as an investor. If you sell some holdings in a given year and reap a total capital gain of $10,000, you'll be on the hook to fork over $1,500 to Uncle Sam, keeping $8,500 for yourself. If your gain was short-term, though, you might be forking over $2,500 or more.

You can pay even less
Here's some good news: You can offset your capital gains with your capital losses -- and if you've been a bad or unlucky investor, you can end up paying no capital gains taxes at all. Imagine, for example, that you have $10,000 in long-term gains and $5,000 in losses in a given year. Your net gain is just $5,000, and 15% of that is just $750.

If you gained $10,000 and lost $10,000, then your capital gains tax, as you might expect, is zero.

And what if you gained $10,000, but lost $15,000? Of course, you pay no capital gains tax; your entire $10,000 gain is offset by $10,000 in losses. With that leftover $5,000 in losses, you're allowed to offset up to $3,000 of your taxable income, which means you'll pay less in income tax for the year. You'll still have $2,000 in losses left over, which you can carry over into the next tax year to offset gains and/or income if need be.

Avoid the dreaded "wash sale." Photo: Flickr user Kasia.

Given the many ways capital gains and losses can affect your taxes, many investors get strategic about their sales as the end of the year approaches. If you have some realized capital gains that will generate taxes and you're sitting on some paper losses, you might sell some losing holdings in order to realize losses that can offset gains, thereby reducing your tax hit. You can even buy those stocks back again if you want to continue holding them; just be sure to wait more than 30 days. If you buy an asset back within 30 days, the IRS considers the sale to have been a "wash sale," and you don't get to offset your gain with it.

So there you have it -- the capital gains tax rate in a nutshell. The rate you face might be 15% or more, but if you're investing for the long term, then you're getting a substantial break from the IRS.