Headsets attaches the fork to the frame, they consist of bearings and races which allow the forks steerer to move within the frames headtube.
Threaded headsets are the older type and use a thread on the forks steerer to adjust,
Ahead type has no thread and uses a top cap to adjust the tension. Ahead headsets come in three options, external cup, internal and integrated. Integrated and internal headsets use bearings which fit inside the headtube and provide clean lines.
External cup system uses cups which fit into the frame but are still visible.