What if I hold the stocks in a 401(k) or IRA?

If you own stocks or stock funds within a traditional IRA or 401(k), you don't have to pay taxes on dividends or on stock sales (that is, on realized gains) as long as the investments remain in the account. That's a mammoth advantage.

A reminder, though, that you'll owe regular income taxes on the money when you withdraw it in retirement. (That's for traditional IRAs and 401(k)s; the rules for Roth versions of those plans are different.)