Three years ago, while she was on maternity leave, Ros Ball and her partner, James, began a diary of their children's lives. Their daughter Josie was three and their son Clem three months old. They wanted to record the moments when their children were made aware of gender stereotypes; when they were directed towards a view of the world in which girls and boys inhabit separate, rigid spheres of pink and blue – the first sphere passive, pretty and gentle, the second aggressive, active and strong.

The results were tweeted under the title Baby Gender Diary, and Ball, a broadcast journalist who lives in London, couldn't believe how much there was to write about. On the first day, they went to a pantomime with a toy stall, where Josie's older male cousins directed her straight towards the sort of item supposedly beloved of small girls: a fluffy pink tiara. One of these boys then chose a flashing torch, in pink, for himself, to which the stallholder responded: "Shall I get you that in blue?" The boy, aged about five, readily agreed to the swap.

The next day, when Josie was shown around the nursery she would be attending, a table covered in cars was described specifically as "the boys' corner". Not long afterwards, Ball saw two different children's TV programmes, in quick succession, featuring male characters who were deeply embarrassed to be seen wearing the colour pink.

Ball was inspired to start the project after reading There's a Good Girl by the German lawyer and writer Marianne Grabrucker. The book was an international bestseller when first published in the 80s, and charts the gender stereotypes Grabrucker's daughter Anneli was subject to, starting from her birth in August 1981. At the time Grabrucker was keeping the diary, these stereotypes were under attack, and seemed likely to weaken in future or even sputter out entirely. Second-wave feminists of the 60s and 70s had analysed gender roles and kickstarted a trend for non-sexist parenting, built on a determination to bring up children free to embrace what interested them – be it maths, construction and cars for girls, or fashion, dolls and cookery for boys.

In the years since, there has been obvious progress towards gender equality in the adult world. Many more women have moved into the workplace and public life, many men have taken on a greater share of domestic chores, and gay and transgender people have fought strongly, often successfully, for greater rights and visibility. Yet when it comes to the world of children – the toys they play with and the clothes they wear – stereotypes have never been so defined, or rigidly enforced. Pink and blue have triumphed in the toy market, and there are often serious social penalties for children who breach the divide. The rise of highly gendered toys is a result of capitalism, but it also suggests a deep, subconscious unease with the advances of the past few decades.

Over the past few years, people across the world have begun questioning this culture. In the US, for instance, a high-school student called Antonia Ayres-Brown wrote this week about a campaign she has pursued since 2008, when she was 11, to stop McDonald's handing out their Happy Meal toys on the basis of gender. She recently received a letter from the company's chief diversity officer, stating: "It is McDonald's intention and goal that each customer who desires a Happy Meal toy be provided the toy of his or her choice, without any classification of the toy as a 'boy' or 'girl' toy."

In Durham, UK, Tricia Lowther has been working equally hard. Her six-year-old daughter, Marianne, loved the Pixar film Cars when she first saw it, and in the supermarket one day, when Lowther was buying juice cartons, "it was a choice between cars and princesses, and I got her the Cars ones, sure she'd like them". Instead, Marianne hid the cartons. When Lowther asked what was the matter, the answer was: "It's boyish." "I said: 'But you like cars, don't you?' And she said: 'I do, but I don't want anyone to know.'"

The association of blue with boys and pink with girls is a comparatively recent phenomenon. Photograph: Alamy

Lowther is part of the campaign Let Toys Be Toys, which began towards the end of 2012 as the result of a thread on parenting website Mumsnet about the explicit gendering of toys. In the space of a year the campaign has convinced 12 major retailers, including Boots, Toys R Us and Marks and Spencer, to remove "girls" and "boys" signage on toy displays. Lowther says she hopes the shops will start categorising products by subject and interest rather than gender. Last month, the campaign expanded to include the Let Books Be Books project, backed by children's laureate Malorie Blackman, poet laureate Carol Ann Duffy and the author Philip Pullman. This asks publishers to stop labelling books as specifically for boys and girls because, as Pullman has said: "No publisher should announce on the cover of any book the sort of readers the book would prefer. Let the readers decide for themselves."

In Australia last year, inspired by Let Toys Be Toys, Thea Hughes and Julie Huberman began the Play Unlimited campaign, and quickly convinced Toys R Us to drop the boys' and girls' categories on its website. When I speak to Hughes, she has just launched a new online petition to stop gender stereotypes being marketed to kids more broadly. Her awareness of the issue deepened when her son Harper, now four and a half, was born. There was heartache, she says, in seeing people's reactions to his love of pink and wearing dresses. "I could see him starting to become aware that he's being judged, and that he's unable to make the choices he'd like to make, because of the social pressure. At such a young age, it's just so sad."

A trip to Hamleys in London at the start of the Easter weekend highlights the problem. In 2011, a campaign by the neuroscientist Laura Nelson led to the UK's biggest toy-shop taking down the signs denoting that one floor was for boys and another for girls. But stereotypes still abound. On the first floor, featuring toys for young children, there's a display of dressing-up outfits, the top rail presumably marketed to girls, the bottom one to boys. There's a bridal gown for three- to six-year-olds, for instance, complete with a fake corsage. As parents and children consider it, Beyoncé booms in the background: "If you like it then you should have put a ring on it." The other costumes on the top rail are a pink cowgirl outfit, a pink waitress costume, a pink and purple superhero costume and a "hair stylist" tabard, in pink with purple trim, complete with plastic comb, mirror, scissors and hairdryer. The boys have two options: blue police-officer outfit and blue superhero costume.

Up another floor and there's no need for a "girls" sign. A woman behind me on the escalator says to her daughter, "I think this might be the girlie floor. It looks a bit girlie, doesn't it?" There are pink cleaning sets, cooking utensils and hairstyling kits. The Barbie display features construction sets for a ballet studio, a fashion boutique, an ice-cream cart and a luxury mansion. Next to it is the Disney Princess stand. When US writer Peggy Orenstein analysed princess culture in her 2011 book Cinderella Ate My Daughter: Dispatches from the Front Lines of the New Girlie-Girl Culture, she noted that there were 26,000 Disney Princess products on the market, and that the franchise was the largest in the world for girls aged two to six – all dreaming of their future prince. The range epitomises the heightened fantasy femininity sold to girls today. A couple of floors up, on what seems to be the boys' floor, Scalextric sets are stacked next to Hornby toys, Airfix models and a host of remote-controlled cars.

The justification for this kind of gender segregation is usually that it's natural and traditional – that it's always existed. In fact, the connection of blue with boys and pink with girls is relatively recent, as fashion historian Jo B Paoletti notes in her book Pink and Blue: Telling the Boys from the Girls in America. Paoletti writes that, in the Victorian era, both boy and girl babies were dressed in white gowns and there was no attempt to signal a child's gender. In the first half of the 20th century, rules began emerging for pink and blue, but they were loose, with some seeing blue as a girl's colour because of its association with the Virgin Mary. The rules often had nothing to do with gender. "I've seen paper dolls up through the 1920s and 30s," says Paoletti, "where the pattern was blue for blue-eyed children, and pink for brown-eyed children. There were lots and lots of little brown-eyed boys who got pink presents for their first birthday."

A boy with a doll. Photograph: Tom Gautier Photography/Getty Images/Fototrove

By the 50s, pink had become strongly associated with femininity, but boys still often wore it, while by the 70s, the two colours certainly didn't dominate the toy market. Paoletti writes that during the heyday of unisex parenting, which lasted from 1965 to 1985, "pink was so strongly associated with traditional femininity that it was vehemently rejected by feminist parents for their daughters' clothing. At the height of the trend (the mid-1970s), Sears catalogues" – mainstream shopping catalogues in the US – "carried no pink clothing for toddlers, and only a few pink items for babies."

This pattern is clear in the UK too. In the Argos catalogue for 1976, primary colours, particularly red and yellow, adorn the toy pages – most of the bikes are red, as is the packaging for a Spirograph. The toy typewriter is yellow. There are gendered products on offer, such as a Girls' World head, for applying makeup, but the packaging is a very long way from the pink, glittering fantasy femininity of today.

One obvious reason for the triumph of pink and blue is that segmenting the toy market brings greater profits by making it harder for parents to pass down items between siblings of a different sex. If your daughter has a pink bike with streamers on the handlebars, and those elements are understood as distinctly feminine, then you're far less likely to hand it on to your son. Instead, you'll probably buy another.

Elizabeth Sweet, a researcher at the University of California, Davis, who has analysed the changing shape of the toy market, says the growth of marketing generally has also been influential. In the US, regulations around TV advertising to children were stripped away in 1984. "And so immediately thereafter," she says, "all of the toys began to have shows associated with them, and the ties between the toy industry and the entertainment industry became virtually indecipherable. So you have the Transformers movies, the My Little Pony movies, and these entertainment lines were often developed according to gender, right? I think that relates to the fact – and toymakers know this – that young children are very receptive to gender stereotypes at that developmental stage where they're forming their own gender identity, so two and three years old. Toymakers have certainly exploited that."

Young children are ripe for this kind of exploitation. When they are between the ages "of about three and five-ish – give or take, depending on the child", says Paoletti, "they understand what gender is, and what their gender identity is. They understand that they're a boy or a girl, and that that's a very important thing. But they don't understand that this is necessarily permanent. They really do think that a little girl who gets her hair cut is now a boy, and a boy who wears a dress is now a girl, which is a very, very scary thing. So if you market toys to them and say, 'Here's the boy one, and here's the girl one,' out of sheer self-preservation of their identity, they're likely to pick the one that's appropriate to their sex."

Sweet suspects another culprit in the gendered, highly sexist toy market is the male dominance at the top of toy and advertising companies, and in Pink and Blue, Paoletti suggests another intriguing idea: that the rise of ultrasounds during pregnancy has contributed to the triumph of gendered colour codes. Before this technology, parents tended to buy neutral colours when preparing for the birth of a child. With many now discovering their baby's sex before birth – and that being the only information they have about what their child might be like – products are bought on that basis. "People like to categorise things," says Paoletti, "and it's just fun to say, 'We're going to have a little girl!' and run out and get something girlie. I don't think anybody anticipated that there would now be two kingdoms of pink and blue, with a big wall between them, that children are not supposed to cross."

A toy tiara. Photograph: Alamy

But that has certainly been the case. In the US, in the last few months, there have been two separate stories of boys being bullied for their love of My Little Pony. In March, for instance, it was reported that nine-year-old Grayson Bruce had been told not to bring his My Little Pony bag to school in North Carolina because it was a trigger for the bullying he was experiencing, which has included punching, pushing and name-calling. (His school has since reversed that decision.) Earlier this month, the mother of 11-year-old Michael Morones, also of North Carolina, spoke about his recent suicide attempt, which has left him in a persistent vegetative state. The reasons for self-harm are always complicated, but Morones had experienced problems with bullying. He tried to kill himself the evening he told his mother: "I am so tired of people at school calling me gay because I like My Little Pony."

Boys are especially stigmatised for crossing the gender aisle in toys and clothes – a fact that seems to arise from a deep misogyny, homophobia and transphobia: a suspicion of any boy who embraces femininity, which is considered synonymous with weakness and subordination. The campaigners and parents who are fighting for more gender equality in the toy market are well aware of this, and there's a move away from the specific negativity towards femininity and pink that has sometimes characterised the debate.

The other problem with gendered toys, of course, is the way they limit children's interests. Chi Onwurah, MP for Newcastle upon Tyne Central, called a parliamentary debate on gender-specific toy marketing earlier this year after one of her constituents, a woman scientist, wrote to her about the products for little girls she saw each day on the way to work: pink flowers, fairies and princesses. Onwurah worked for decades in the engineering sector herself, and believes the limiting of children by gender stereotypes is a serious economic issue. When she began her engineering degree, 12% of her peers were women – 30 years later, that proportion is down to 8%. "We have some big economic problems," she says, "and one is a huge skills shortage in engineering and technology. There are thousands of jobs going unfilled, and in addition a lot of our engineers are in their 50s and retiring in the next five years. At the same time we have the lowest proportion in Europe of women who are professional engineers."

If girls are given the constant message that science, technology and construction are not for them, this is unlikely to improve. Onwurah grew up playing with a yellow pogo stick and riding on a red bike, and her favourite present when she was nine was a microscope. "Toys are so important and formative," she says, "and for me this is about the jobs of the future, about what happens in 10 or 15 years' time. We can't go on with a segregated society."