Harassment is much less frequent than the Spanish stereotypes would have you believe, and though the country has one of the developed world’s lowest incidences of reported rape, there have been some high-profile cases of violence against women in recent years in Spain. Any unpleasantness you might encounter is more likely to come from drunken northern-European yobs in the big resorts than from the locals.
In towns you may get the occasional unwelcome stare, catcall or unnecessary comment, to which the best (and most galling) response is indifference. Don’t get paranoid about what’s being called out; the piropo – a mildly flirty compliment – is deeply ingrained in Spanish society (even though it will generally make women feel uncomfortable).
Topless bathing and skimpy clothes are generally OK at the coastal resorts, but otherwise a little more modesty is the norm, although lots of Spanish women bathe topless now.