If you have been a Resident in Spain for more than 3 years and are above 65 years of age, upon the sale of your main residence in Spain, you may not be liable for Capital Gains Tax.
If you bequeath your main residence to your spouse or children who are also Resident in Spain and have been for the previous 3 years, they may also be exempt from inheritance tax (99% in the autonomous Region of AndalucĂa). Values vary from Region to Region.