Trading and taxes go together like a horse and carriage: Any time you sell stock in a regular brokerage account, there's a good chance you're going to end up paying some taxes. But you never want to pay any more tax than you have to.

Luckily, there's a method you can use to reduce or even eliminate taxes when you sell stock -- even shares you own in a taxable account. Although those who buy all their shares in a single transaction can't take advantage of it, those who have an ongoing investment plan, and who add to their positions over time, should always keep it in mind when they decide to sell shares.

How can you save? Just pick the right shares.

Sidestep capital gains
When you sell shares of stock, the IRS has rules to follow to help you determine how much gain or loss you have. The default rule the IRS uses for stocks is that the first shares you bought are also the first shares you sold. This so-called "first-in, first-out" or FIFO rule forces you to use whatever tax basis you have for the shares you've held the longest.

Sometimes, that's exactly what you want to do. For instance, if you own some shares with short-term gains and others with long-term gains, the FIFO rule will have you sell the long-term shares first, letting you take advantage of the maximum 15% capital gains rate.

But generally, the shares you bought first are also the ones you paid the least for. That, in turn, means that your first shares often have the largest gains.

If that's the case for you, then you'll want to know about one alternative method. Rather than simply accepting the default FIFO rule, you can specify exactly which shares you want to sell. That can cut the amount of gains substantially, reducing your tax bill.

The aftermath of the bear
After a bear market that has lasted more than a year, choosing the right shares can mean the difference between a gain and a loss. For instance, say that in 2008, you owned 100 shares of some stocks you'd bought back in 2003. You then decided to buy another 100 shares. Take a look at several examples of stocks where you'd have a big gain under the FIFO rule, but could claim a capital loss by selecting the 2008 tax lot to sell:

Stock

Gain On 2003 Shares

Loss On 2008 Shares

Net Tax Benefit

Celgene (NASDAQ:CELG)

$3,994

($1,537)

$830

Monsanto (NYSE:MON)

$8,009

($2,607)

$1,592

AT&T (NYSE:T)

$1,041

($947)

$298

Costco (NASDAQ:COST)

$1,876

($1,741)

$543

Goodrich (NYSE:GR)

$2,881

($1,513)

$659

Goldman Sachs (NYSE:GS)

$4,481

($6,135)

$1,592

Range Resources (NYSE:RRC)

$4,132

($1,919)

$908

Source: Yahoo! Finance. Assumes 15% capital gains tax rate for savings.

Some basic rules
To claim this great perk, you have to follow one important rule: You must get your broker to acknowledge your choice at the time you sell the shares. You can't go back at tax time and make the decision then.

In fact, because of new tax laws that take effect as early as 2011, brokers will have to report cost basis information to the IRS. That makes following the rules here even more critical. If you don't, the information your broker reports to the IRS won't match up with your tax return -- which is a big red flag that could create a nasty audit risk.

Sure, picking tax lots may not seem like a big deal. But the difference on your taxes can be huge. It's worth the extra effort to make sure you save as much as you can.

Get more great investing tips:

Learn more about smart investing from Fool co-founders David and Tom Gardner each month in their Motley Fool Stock Advisor newsletter. You can try it for free with a 30-day trial.

Frustrated with your 401(k)? Even if your employer's plan isn't the greatest, you don't have to give up your dreams of a happy retirement. Get the tips you need to turn your retirement savings around in our special report, "How To Make The Most of Your 401(k)." Just click here for instant free access.

Fool contributor Dan Caplinger has been picking tax lots for years. He doesn't own shares of the companies mentioned in this article. Costco is a Motley Fool Inside Value selection and a Motley Fool Stock Advisor pick. Try any of our Foolish newsletter services free for 30 days. The Fool's disclosure policy helps you make the right choice.