From SolarSailWiki

As every sailor knows, to tack or beat a sailboat is to sail the boat at an angle into the wind. Solar sails can do their own form of tacking by using the force of sunlight pushing out from the sun to actually move closer the sun.

Spacecraft, including solar sails, travel around the sun in orbits. A spacecraft that is propelled by a rocket can shrink its orbit, and thus move closer to the sun, by thrusting the rocket in the opposite direction as the spacecraft's motion. Similarly, if a solar sail can produce thrust in the opposite direction as the spacecraft's motion, its orbit will also shrink. By producing thrust in the same direction as the spacecraft's motion, the orbit will expand, and the spacecraft will move farther away from the sun.

A rocket can thrust opposite its motion by pointing the rocket engine forward along the path of its motion. This produces a force from the rocket engine that is in the opposite direction as the spacecraft's motion.

Solar sails are more complex. The force produced by sunlight on a solar sail is the addition of the forces from the incoming sunlight and the reflected sunlight. This force always points away from the sun, and is at an angle that is close to a right angle to the surface of the sail. If this force is angled back along the solar sail's path, the spacecraft's orbit will start to shrink, bringing it closer to the sun. If the force is angled foreward along the spacecraft's path, the orbit will grow and the solar sail will head farther from the sun.

This is the general idea behind "tacking into the sun" for solar sails. In real practice, the behavior of a solar sail is more complicated because sunlight pushes not only along the spacecraft's orbit, but also straight out from the sun. These effects are beyond the scope of this document, however.

To visualize how this works, take a look at the following images.

Travelling away from the sun:

Travelling towards the sun: