Please follow https://www.irs.gov/newsroom/homeownership-and-taxes-things-taxpayers-should-consider-when-selling-a-house.