As voters cast their ballots, election officials collect and count them. This process takes place throughout the days and weeks after Election Day and involves both counting early in-person and mail ballots and a final certified vote count. News media use these results to make predictions about the outcome of an election (often referred to as a call). But, these predictions are unofficial and can change for hours, days or even weeks until all votes have been counted and the official results are certified.
These predictions are based on polls and projections that ask randomly selected people who they voted for and how they expect others to vote. As with all polling, these surveys have a margin of error.
The results from the polls and projections are compared against actual voting data that is collected on election night and in the immediate days after the polls close. As the vote counts come in, media outlets collect the data and analyze it to determine which candidate or party will win each race. News media then releases these predictions, often using a graphic such as this one (click for an interactive version) to help people understand the election results.
Then, as more ballots are counted, each news outlet compares their prediction to the full result to ensure accuracy. Then, the official result is certified by state and local election officials. This can take days or weeks and may involve a recount where ballots are examined by hand or re-scanned with a machine to see if any errors were made in the initial count.