Sunscreen can partially block the skin's ability to produce vitamin D from sunlight, but it's still essential to protect your skin from excessive sun exposure. The pros of sun protection will outweigh the cons of losing out on an insignificant amount of vitamin D from the sun.