People coming to live in Spain should be aware that one becomes tax resident if :-
their centre of economic activity is in Spain,
they move here,
their family live here,
they have no other country where they are registered for tax,
if they spend 183 days or more in any year in Spain.
NB The last condition applies ONLY if the others do not.
If one becomes tax resident in Spain they are obliged to declare their worldwide income.
NB For the whole of the year, 1st Jan to 31st Dec. in which they move they are tax resident in Spain.
Thus if one sells a property in UK in November and moves to Spain, they have a tax liability on the capital gain they made on the UK house. That they were not actually tax resident when they sold the property makes no difference.
Anyone who may fall within the confines of these laws would be wise to seek very good financial advice.