Deductions & credits

You can't avoid tax on your gain by buying a new home, that provision of tax law was eliminated decades ago.  If you have a gain, you owe capital gains tax unless you qualify for the exclusion.

To qualify for the exclusion, you must have owned the home at least two years and lived in it at least two years of the past 5 years, and not have used the exclusion within the 731 days prior to the closing date of the sale.  The exclusion is $250,000 for single or $500,000 for married filing jointly.  If you moved early due to certain financial hardships, you may qualify for a partial exclusion of gain, but changing your mind or finding a better house is not a qualifying hardship.

If you have a taxable gain, you will want to document all the adjustments you can.  You increase your basis by certain closing costs from the purchase (inspections, legal fees, mortgage recording fees and taxes) and you can adjust the selling price by subtracting selling expenses such as real estate commission and legal fees and other selling costs.  Then you owe gains tax if you have a gain, long term rates if you owned more than one year; short term if you owned less than one year.