sounds like you've been watching one of those holiday homes abroad disaster stories that itv is so fond of showing. like in most countries, inheritance tax is a complicated affair. basically what happens here is that when you die and leave your estate to someone they are taxed. the closer they are realated to you and the younger they are the bigger the amount of tax free allowance before the tax rate kicks in. it's a sliding rate based on the size of the estate so you pay a higher rate of tax on a million euro villa than a studio in figueretes. finally, the ultimate test is the wealth test on the person who inherits, the richer he is, the more tax he pays.
so, tips.
buy your property in joint names and get a spanish will. don't leave it to roman abramovich unless he's your only son.
there are lots of websites which deal with this subject, just google spanish inheritance tax
of course, you could just get yourself a lawyer who works for spain's partido popular and you'd end up with the government paying you 80% when you die! (allegedly)