Image copyright Getty Images

A social media storm erupted on Sunday when two girls were stopped from boarding a United Airlines flight because they were wearing leggings.

The girls were flying as guests of employees, and thus were subject to the company's dress code.

But it is not the first time leggings or yoga pants have caused controversy in the United States.

Both types of tight-fitting trousers, which have become increasingly popular leisure wear, have become the topic of hot debate in recent years.

For many, they are simply a comfy alternative to jeans.

For others, their form-hugging material makes them overly revealing or even obscene.

Last October, a man in the US state of Rhode Island sent a letter to his local newspaper, calling for women over 20 to stop wearing them.

"Like the mini-skirt, yoga pants can be adorable on children and young women who have the benefit of nature's blessing of youth. However, on mature, adult women there is something bizarre and disturbing about the appearance they make in public," wrote Alan Sorrentino.

It sparked a "yoga pants protest". Hundreds of women of all ages responded by walking through the town of Barrington wearing leggings.

Image copyright Science Photo Library Image caption Yoga pants have moved from sports wear to casual streetwear

Jamie Bee, one of the protest's organisers, told the BBC the outrage was never really about yoga pants.

"For me and many others, it's the principle," she said. "Why do people feel the need to tell others how to dress?"

Mr Sorrentino, who said he received threats after the backlash, later said his letter was meant as satire.

But across the world, some women are fighting back against restrictions on what they can wear, from burkinis to comfortable footwear.

Stretching the rules

United Airlines has since clarified that regular passengers are not subject to the same leggings ban as the girls on Sunday's flight.

But the dress code, which applies to staff and their relatives travelling on special passes, states a ban on "form-fitting lycra/spandex tops, pants and dresses", among various other restrictions.

Read more:

Flight attendant and author Heather Poole said, on Twitter, that airlines often have dress codes for staff travelling for free, as they are seen as representing the company.

"Men have a dress code too. This is about being too 'casual'. We can't wear flip flops or shorts either," she wrote.

'Cover your buttocks'

Various US schools have also attracted controversy with their policy on leggings.

In Ohio, the Lakewood city school district revised its dress code last year following complaints that it had outdated and sexist elements.

Tight-fitting trousers, including leggings and yoga pants, went from being banned to permitted, but only if "the garment worn on top covers the buttocks".

Image copyright Getty Images Image caption Leggings have moved beyond the gym

Other amendments to the code included allowing hooded sweatshirts, as long as the hoods are not covering a student's head. They also upped the minimum length of skirts from "slightly above the knee or longer" to "mid-thigh or longer."

In 2015, students at Cape Cod Technical College in Massachusetts planned a protest against dress code changes that prohibited them from wearing yoga pants and similar clothing without wearing a skirt, dress or shorts over the top.

School superintendent Robert Sanborn argued that the policy was designed to prepare students for the working world.

"Part of our framework for our school is employability skills, and there's proper dress for that," he told the Boston Globe at the time.

The school did not back down and the dress code still stands.

The sheer cheek of it

In some cases, the argument has boiled down to whether or not the clothing is new. Threadbare leggings can be much more revealing.

In 2013, Lululemon, a sports-clothing company, had to recall many of its leggings because they were considered too sheer.

Founder Chip Wilson later made matters worse by saying the company's trousers were not meant for all women's bodies.

Image copyright Getty Images Image caption Retailer Lululemon took some of its yoga trousers off the market in 2013 because they were considered too sheer

Get news from the BBC in your inbox, each weekday morning