Image copyright AFP/Getty Image caption Attitudes have changed dramatically in past decades, Labour leader Ed Miliband told Gay Times

A gay prime minister would be accepted by voters, Nick Clegg and Ed Miliband have said.

The deputy prime minister said he or she would be judged on their "ability to lead" rather than their sexuality.

Both he and Labour leader Mr Miliband were responding to questions from readers of Gay Times magazine.

In an open letter to the same publication, Prime Minister David Cameron said more gay role models were needed in the world of sport.

He added that clubs had to do more to "tackle problems on the terraces" and praised sports people who have been open about their sexuality.

It's not a choice, it's who you are Nick Clegg

Asked if the public was ready for a prime minister who was openly gay, Mr Clegg replied: "Yes and why not?

"Being gay doesn't affect how you work, how you interact with people or how you make decisions.

"I'm confident that the British people would judge him or her on their ability to lead and be a good prime minister and not on who they choose to share their life with."

Image copyright Reuters Image caption The three politicians have been giving their views to Gay Times magazine

Mr Miliband agreed, saying he could see there being a gay prime minister in the UK in the future because of the way attitudes have evolved, bringing a series of changes including same-sex marriage.

He told Gay Times: "I think the world has changed a lot.

"If you think about the way the world has changed in the last 20 years since I was at college, we've seen the repeal of Section 28, we've seen civil partnerships, the lowering of the age of consent, equal marriage - and that has been driven by change in social attitudes, and that is why I think absolutely it's foreseeable to have a gay prime minister."

Both politicians are fathers to sons and said they would have no problem if one of them said he was gay.

'Break down barriers'

Mr Miliband said: "I would love them equally as much.

"The most important thing to me is that my kids are happy and I don't care whether they're gay or straight. That's what matters to me."

On the same subject, Mr Clegg said: "I would have no issues at all if one of my boys told me that he liked another boy.

"It's not a choice, it's who you are and I would love my boys regardless of their sexuality. I just hope that some day coming out to your parents is not going to be something you dread but something you will remember fondly."

Image copyright Getty Allsport Image caption Former Wales rugby captain Gareth Thomas was praised by David Cameron

Mr Cameron used his open letter to say he was proud to lead a country judged the "best place to live in Europe if you are lesbian, gay, bisexual or trans(gender)."

He spoke of the need to "break down barriers" in sport, adding: "We have seen the enormously positive reaction to people like Thomas Hitzlsperger and Gareth Thomas being open about their sexuality, and hopefully that will encourage others to be more open too.

"But we need more role models, straight and gay, to encourage the best behaviour and clubs must tackle problems on the terraces."

UKIP leader Nigel Farage also contributed to the magazine and was asked if his party would pledge to expel members who were homophobic.

He replied that UKIP was not "the thought police", saying: "It would sound great to say, 'yes, we would expel anybody who was a homophobe', but how would that be judged, or investigated or enforced?"

Mr Farage told the magazine, published digitally on Friday: "Even within one section or group of society there will be very different notions of what is fine and what is deemed insulting or upsetting."