I owned my condo for 10 yrs. Looking to sell it. I lived there for 18 mo. out of the last 5 yrs. Do I have to pay ALL capital gains tax or can I write off the 18 months?

I know there is capital gains for rentals but can I prorate since I was there 18 months?