Investors & landlords

No.  For 401K accounts you don't pay tax on dividends or any transactions inside the account.  That's the benefit of a 401K account.  It is all tax deferred until you take it out.   You don't need  to track the cost basis or anything.  When you take a withdrawal it is all taxable as ordinary income.  You don't get any capital gains treatment on it.