WASHINGTON (Reuters) - President Barack Obama said in a commencement speech on Saturday that U.S. race relations have improved over the last three decades, but that significant work still needs to be done.

“I tell you this not to lull you into complacency, but to spur you into action because there’s still so much work to do,” Obama told about 2,300 Howard University graduates in Washington, acknowledging that racism and inequality still persist. “We cannot sleepwalk through life,” he said.

The United States has faced a number of racial controversies in recent years, including the 2014 shooting of an unarmed black teenager by a police officer in Ferguson, Missouri, that sparked sometimes violent protests.

The United States has a racial gap in economic opportunities, Obama said, noting that the overall U.S. employment rate is around 5 percent, but it is near 9 percent for African-Americans.

Obama, the son of a white mother and African father, told the graduates to embrace their racial identity.

“Be confident in your blackness,” Obama said, adding “there is no one way to be black ... There’s no straightjacket, there’s no constraints, there’s no litmus test for authenticity.”

He added that “my election did not create a post-racial society,” but was one example of how attitudes have changed.

Slideshow ( 6 images )

Obama also urged the crowd not to try to prod colleges and universities into disinviting controversial speakers - something that has taken place regularly at campuses throughout the United States.

Howard University is one of about 100 historically black colleges and universities in the United States.

Obama argued that the United States and the world has progressed dramatically since 1983 when he graduated from college.

“America is by almost every measure better than it was” in 1983, Obama said, noting that U.S. poverty rate is down, the number of people with college degrees is up and the number of women in the workforce have risen.

Obama said today’s college graduates are better positioned than any other to address the country’s tough outstanding problems.

“You need a strategy,” Obama said, adding passion and anger are not enough to effect political change and encouraging them to embrace compromise. “Not just hashtags but votes.”

Slideshow ( 6 images )

He noted the low voter turnout among young people in the 2014 congressional elections. He told the graduates they needed to vote “every time ... not just when you’re inspired.”

But Obama noted an area that has not improved in recent decades - the U.S. prison population - currently at 2.2 million, it is up more than fourfold from 500,000 in 1983.

African-American men are six times more likely than white men to be incarcerated, Obama said, and urged the graduates to lobby the U.S. Congress to pass a pending criminal justice reform measure.

Senator Charles Grassley, an Iowa Republican, praised Obama’s remarks on Twitter, writing “even conservatives would applaud it.”