You may avoid tax on gain on the sale of a principal residence if you owned and used it for at least two years during the five-year period ending on the date of sale. If you are single, you may avoid tax on up to $250,000 of gain, $500,000 if you are married and file jointly. However, gain attributable to nonqualified use after 2008 is not excludable (29.2).
If you used the residence for less than two years, you may avoid tax if you sold because of a change of job location, poor health or unforeseen circumstance (29.4).
You may not deduct a loss on the sale of a personal residence. Losses on the sale of property devoted to personal use are nondeductible (29.8). However, there are circumstances under which you may claim a loss deduction on the sale of a residence (29.9–29.10).
If you rent out a residential property and you or family members also use the residence during the year, rental expenses are subject to special restrictions (9.7).
If you sell (or exchange) your principal ...