Get your taxes done using TurboTax

There's no connection between the sale and the purchase.  Any rules relating the two were eliminated in 1997.

 

You pay capital gains tax on the gain from the sale.  If this was your main home and you lived there as your main residence for at least 2 of the past 5 years (731 days, does not have to be consecutive), you can exclude the first $250,000 of capital gains from taxation, whatever is over the limit is taxed per usual.  If you are married filing jointly, or you are a widow and you sell in less than 2 years from the date of your spouse's death, you can exclude the first $500,000.

 

Whatever you do with the money is irrelevant to how the sale is taxed.  

 

Your capital gain is the difference between your cost basis and the selling price.  Your cost basis is what you paid, plus the cost of any permanent improvements (remodeling, new roof, etc.) minus an adjustment for depreciation if the home was ever used for business.  You can also include in your cost basis, certain closing costs from the purchase, and you can reduce your selling price by certain costs of selling.

 

For all these rules, see publication 523.

https://www.irs.gov/forms-pubs/about-publication-523