The IRS states that "If your capital losses exceed your capital gains, the excess can be deducted on your tax return." Limits on such deductions apply. Special wash sale rules apply if the same or substantially similar asset is bought, acquired, or optioned within 30 days before or after the sale.
According to 26 U.S.C. §121, a capital loss on the sale of a primary residence is generally tax-exempt.. IRC 165(c) is a stronger source that limits the loss on the sale of a personal residence. IRC 121 is for exclusion of gain of primary residence and does not talk about loss.