You dont get taxed until you sell. The performance shown here is for a buy and hold strategy.
Granted, IRA/401k etc exist and in years with 0-3% it's not that big a deal, but over 20 years it's often a significant cost.
Only if you never withdraw them.
http://avondaleam.com/sp-500-dividend-vs-10-year-treasury-yi...