One of the unwritten rules of social media is avoid inspirational quotes.

American astronaut Scott Kelly put that to the test on Sunday when his use of Winston Churchill quotes landed him in hot water with people who oppose the wartime British prime minister's views on empire and race.

But when Kelly tried to apologise for the tweet and offered to educate himself, Churchill fans attacked him for discrediting the politician's record.

Kelly, whose sister-in-law is former Democrat Congresswoman Gabrielle Giffords, used a famous remark by Churchill to comment on deep divisions in American politics.

The wartime leader wrote "In victory, magnanimity" in his book about World War Two to refer to the need for winners of a conflict to show grace. Kelly added: "I guess those days are over".

But Churchill is also known for quotes like "I do not admit that a wrong has been done to these people by the fact that a stronger race, a higher-grade race, a more worldly wise race to put it that way, has come in and taken their place", in reference to indigenous populations of North America and Australia.

Kelly's Twitter followers also linked Churchill to a famine in Bengal, India, that killed at least three million people in 1943.

Kelly quickly apologised for the offence caused, writing that he would educate himself on Churchill's "atrocities and racist views".

He added that his point was that Americans should not let politics divide the nation

But he was swiftly attacked by Churchill fans for calling the leader racist.

They suggested those views were standard in the mid-20th Century.

"Please read a good biography of Churchill before making pronouncements on his 'atrocities' and 'racist views'. He committed no atrocities and his views on race 100-years ago cannot be judged by today's standards - generational chauvinism," wrote Twitter user Paul Reid.

"We can't judge historical figures based on modern sensitivities; no one would come out unscathed. Adjusting history to our modern perception is unfair to the times & circumstances that preceded us," commented another.

In just two tweets, Kelly wrote another social media rule - never quote Winston Churchill.