Image source: Getty Images.

The tax code is written to favor investors. Long-term capital gains are taxed at a lower rate than income tax you pay on income earned by trading your time for money at a job. Therefore, from a tax perspective, it's much better to have your money work for you, rather than work for your money.

Here are five things you should know about capital gains taxes, with some tips for reducing your tax bill.

1. Capital gains can come in two forms: short-term or long-term gains

Capital gains from investments held for less than one year are short-term capital gains and are taxed as ordinary income. Gains from investments held for more than one year are long-term capital gains and qualify for lower tax rates across the board.

Ordinary Income Tax Bracket

Short-Term Capital Gains Tax Rate

Long-Term Capital Gains Tax Rate

10%

10%

0%

15%

15%

0%

25%

25%

15%

28%

28%

15%

33%

33%

15%

35%

35%

15%

39.6%

39.6%

20%

One of the reasons it's advantageous to hold investments for a long time is because holding for longer periods can result in less taxation. If you earn your marginal dollar in the 15% tax bracket, you'll pay no tax on long-term gains, but incur a 15% tax rate on short-term gains. 

2. Capital gains tax is the only voluntary tax

If you earn an income, you have to pay income taxes. When it comes to capital gains, you decide when they become taxable. 

Suppose you buy a stock for $20 per share. Several years later, the business has performed spectacularly, and shares now trade for $100 each. You have a capital gain of $80 per share, but you don't have to pay taxes on that gain until you sell.

Legendary investor Warren Buffett has famously used tax law to his favor by holding his winners forever, pushing off any taxes on the gains. For most investments, you hold the ultimate decision on when you should pay a capital gains tax by deciding when to realize the gain by selling at a profit.

3. Real estate may be exempt from capital gains tax

Some capital gains can be earned and realized tax free. When you own your own home, you might be able to avoid paying taxes on its appreciation when you sell it.

The first $250,000 of capital gains on your home is tax-free for single people, and increases to $500,000 for married couples who file taxes jointly. You just have to meet some simple requirements. First, the home has to be your primary residence. Secondly, you must have owned your home for at least two years, and you must have lived in the home for at least two of the last five years.

In other words, most people who own their own home and live in it like, you know, normal people, can avoid capital gains taxes on its appreciation over time.

4. Capital losses can offset capital gains

Many investors use a trick known as "tax loss harvesting" to realize capital losses at the same time they realize capital gains. For example, suppose you own two stocks, one with a $10,000 gain and one with a $10,000 loss.

You want to realize the gain on the winner, but you aren't too eager to pay the taxes on your gain. That's understandable. In some cases, it may make sense to sell both stocks, realize the $10,000 gain on one, and the $10,000 loss on the other, and thus report $0 in net capital gains.

Losses in excess of your gains can be particularly valuable. You can deduct up to $3,000 of capital losses in excess of gains against ordinary income each year. Ordinary income is taxed at a higher rate than capital gains, so the tax savings are even larger. 

5. You can avoid all of the capital gains tax hassle with a retirement account

Taxes are complicated, and virtually every tax rule carries an asterisk and fine print. If you'd prefer not to think about how to best harvest tax losses, or whether it would be smarter to sell a stock this year or next year, there's a really simple way to ignore it all: Use a retirement account to hold your investments.

With just two accounts -- a 401(k) and IRA -- savers can stockpile up to $30,500 of their own money in an account that isn't subject to capital gains tax rules.

Maximum Annual Contributions by Age and Retirement Account

Age

401(k) limit

IRA limit

Total annual limit

Younger than 50

$18,000

$5,500

$23,500

50 or older

$24,000

$6,500

$30,500

Generally speaking, long-term investments for your future are best made within the confines of a tax-advantaged retirement account. And with up to $23,500 to $30,500 in maximum annual contribution limits between these two accounts in 2017, most people will find that they can save all they want to without having to think about capital gains taxes at all.