Sadly however the US presidential election is not decided by the total number of votes, but rather by the Electoral College, which was established as part of the constitution to elect the nation’s president.
It is made up of 538 electors who cast votes to decide the President and the Vice-President. When voters go to the polls, they are voting for the candidate who will receive their state’s electors. To win the presidency, a candidate must receive a majority (270) of votes according to Archives.gov.
Traditionally the Electoral College is reflective of the popular vote, only four other presidents in history have won the election without securing the popular vote.
Most recently it was Al Gore in 2000 who won the popular vote but failed to win the election against George W. Bush. Earlier presidents to also lose the popular vote includ John Quincy Adams, Ruther B. Hayes and Benjamin Harrison.
In 2012 Trump himself slammed the Electoral College system, calling it "a disaster for a democracy."
Whether you agree or disagree, Trump won the election according to the current system as it stands.