Compared to many countries, taxis are reasonably cheap throughout Spain.
However they are not always metered. If not, drivers will carry a booklet of the official rates authorised by the local town hall. There are supplements, such as extra baggage, night service, etc. so it may be prudent to check the price in advance.
Official rates should be displayed at airports and inside any licensed taxi. There are taxi ranks generally in city centres.
It is possible to hail a taxi in the street, just look for the green 'libre' notice on the windscreen or the green light on the roof of the taxi at night. Bars and restaurants will call a taxi for you, if necessary, and tourist guide booklets or newspapers will generally include a few local numbers.
Taxis are excellent value in the city centres where parking and congestion can be a nightmare. They are also a very safe way of traveling.