Retirement tax questions

To put it simply, because you put the money in the 401(k) pretax (that is without paying any tax on it), everything you withdraw is taxable when you withdraw it, even if you withdraw less than you put in because of losses.