But now, a controversial new study has blamed the same public health messages for causing growing numbers of people to suffer from vitamin D deficiency, because they are failing to get enough sunlight on their skin.
Vitamin D is produced by the body in response to exposure from ultraviolet radiation from natural sunlight. It helps protect against cancer and is also thought to be important in helping to prevent bone disease such as osteoporosis, as well as autoimmune diseases, asthma, diabetes, high blood pressure, depression, Parkinson's disease and Multiple Sclerosis.
The researchers are now calling for guidelines on sunlight exposure to be reviewed to ensure people receive enough vitamin D.
Dr Veronique Bataille, who led the study, said: "There has been so much effort put into telling people about the damaging effects of ultraviolet light from sunshine, many now take extreme measures to ensure they don't get exposure by wearing moisturisers with factor 15 all year round.
"We don't want to say that sunbathing is healthy as there is clearly a risk, but people do need a bit of sunshine to stay healthy."
Dr Bataille and her colleagues measured vitamin D levels in the blood of 1,414 white women in the UK and compared this to their skin type and details about the number of foreign holidays, sunbed use and the number of times they had been sunburnt.
They found that those with the fairest skin, who usually have red or blonde hair, had the lowest levels of vitamin D.
Conventional scientific thinking suggests this should not be the case.
People with greater levels of melanin – which is the pigment which causes darker colour in skin – make less vitamin D and there is evidence to show that those with Asian and Afro-Caribbean backgrounds have trouble producing the vitamin.
Dr Bataille, a consultant dermatologist at Hemel Hempstead General Hospital and a researcher at Kings College London, also found that those with fair skin also had the lowest levels of sun exposure through the number of holidays they had abroad and sunbed use.
The researchers concluded that people with fair skin actively avoided sun exposure more, due to their increased sensitivity and so produced less vitamin D. They added, however, there may also be a genetic element that means people with fair skin metabolise vitamin D differently.
The findings come after another study by Dr Bataille's group that showed sunlight may not be the main cause of melanoma, the most dangerous form of skin cancer. Instead they concluded that the number of moles on the skin was a better indicator of risk.
"The advice on sun exposure needs to be reviewed," said Dr Bataille. "It is potentially harmful if people are getting the message that they should completely avoid the sun. The advice needs to be better tailored to the differences in skin type and sun levels around the country."
Experts claim that excessive avoidance of the sun has stemmed from confusing official guidance on sun exposure which has unduly raised fears about the risk of being outside in the sunshine.
Advice on the Health Protection Agency's website states that people should limit unprotected personal exposure to solar radiation, particularly during the four hours around midday, even in the UK. It even warns that sunburn can occur when in the shade or when cloudy.
Cancer Research UK used to advice that people stayed in the shade between 11am and 3pm, the time when the sun is at its hottest and the best time for making vitamin D according to experts. They recently changed their advice to "spend time in the shade between 11am and 3pm" and "aim to cover up".
Vitamin D can be obtained from food, including oily fish and eggs, but it is harder for the body to obtain enough from these sources and consumption of these products in the UK has dramatically declined.
Dr Bataille believes people can make enough vitamin D from just 15 minutes exposure to sunlight while wearing a T-shirt, but added that this would need to be increased for those with dark skin or during the winter months when sunlight is lower.
According to a separate recent study at University College London, 20 per cent of women and 12 per cent of men are now classed as being clinically vitamin D deficient, while levels of the vitamin in nearly two thirds of women and 57 per cent of men are "insufficient".
Dr Vasant Hirani, who led the study, added: "The advice on sun exposure does need to be clarified."
The British Association of Dermatologists has recently issued guidance with the National Osteoporosis Society that recommends people get 15 to 20 minutes of sun exposure a day.
Nina Goad, from the Association, said she doubted public health messages were responsible for causing vitamin D deficiency.
"Vitamin D deficiency is likely to be due to our lifestyles meaning we spend a lot of time indoors, to a lack of vitamin D in our diets, and to our climate meaning we have limited sun exposure for much of the year," she added.
A spokesman for the Health Protection Agency said: "We are not saying that people should avoid all sunlight. Indeed a small amount can help to maintain vitamin D levels.
"Sunbathing incurs the potential hazard without adding to vitamin D levels."