Hello and welcome to the site. Thank you for your question.
Gains arising from sale of property are chargeable to CGT. If the property in question is your main residence, then there is private residence relief available against that gain.
Final 18 months of ownership also qualifies for relief whether you are living in the property or not.
If you were to let your property and provided this property has been your main residence at some point during the period of ownership, there is a further relief available called letting relief. There is a upper limit of £40k on letting relief.
If you acquire a second property, you should nominate one as your main residence and the timescale is up to 2 years of purchase of second property.
If you wish to minimise your exposure to CGT then you should consider moving out of your primary residence to the flat within 2 years of its purchase and make it your main residence from date of purchase.
Sell the primary residence when you retire and your gain would be covered by private residence relief.
Stay in the flat for say one year and sell it to acquire another joint property that would become your main residence again. Gain made on the flat would be covered by private residence relief.
You can treat one property only as your main residence at any one time.
More information on private residence relief is covered in HMRC help sheet 283 here
I hope this is helpful and answers your question.
If you have any other questions, please ask me before you rate my service – I’ll be happy to respond.