The shelter from capital gains for your primary residence is $250K for one person, $500K for a couple. You can take advantage of the tax shelter once every 5 years, provided its different residences - you can't accumulate more tax shelter by living in one house for 20 years.
The basis for calculating how much is "capital gain" is the excess value over what you paid, plus certain capital improvements (not maintenance). The federal rate is in the 25% range for long term capital gains, and states typically tack something on top.
The tax shelter for a dwelling not your primary residence is quite complex, and generally relates to rental properties, which can be sold without paying capital gains - as long as you reinvest in a "like for like" property.