For years the gain on the sale of residence was taxable as a capital gain. Back in the day folks would buy a more expensive home to avoid the capital gains tax. In mid 1997 (I’m writing about this in 2016 because I still get questions about it) the law changed. Now single people are allowed to exempt up to $250,000 per sale every 2 years. That is $500,000 for a married couple.
The law is fairly straight forward. It must be your primary residence for 2 of the previous 5 years and you can take the exemption every 2 years. If your holding period is less than two years then your exemption is prorated based on the time you live in the property. There are some potential caveats that can come into play if you rent the property for some period of time prior to selling. It makes flipping a property while you live in it a real income opportunity.