It has a fair claim to being the best race meeting in the world, but to Britain en masse Royal Ascot is about hats, not horses. It is a place where people aspire to be well-dressed, where they amuse themselves by being over-dressed, where they dress in clothes that would cause a riot if they wore them in their local Waitrose.

There is something charmingly reassuring about the fact that every year, come June, thousands of people choose to put on hats the size of model ships and strut across the sacred lawns like a gathering of human peacocks. Ours is a monochrome world, on the whole, and that glorious explosion of brightness is a scene to lift the spirits: a celebration of frivolity and fun.

The irony is that we owe the existence of this event to a woman not noted for her dress sense. It was Queen Anne who instituted racing at Ascot in 1711, on land that was, and remains, the property of the Crown. Anne was a homely-looking creature whose 18 pregnancies had left her vastly fat; she was far more interested in racing than in what she was wearing while she watched it.

At this early stage in the development of racing – two years before the first recorded use of the term ‘thoroughbred’ – women were an unusual sight, but Anne, like the present Queen, was a true fan of the sport (her horses were trained in Newmarket by Tregonwell Frampton) and she attended avidly.

Known for her close friendships with female ‘favourites’, on one notable occasion she turned up at Ascot escorted by her gorgeous maid-of-honour, Miss Forrester. The maid was not hidden away in the modest custom of the times, but seated on a palfrey and dressed as a man in a long white riding coat, pointed court hat bound with gold lace and a periwig. Unsurprisingly, this look did not catch on.

Ascot became a four-day meeting in 1768. By the end of the 18th century it was hugely popular, with the first running of the Gold Cup in 1809, during the reign of George III. He and his Queen attended regularly, moving among the spectators – ‘amidst the plaudits of the loyal crowd’, as a contemporary writer put it – in that relaxed yet courtly way which still characterises the monarchy’s relationship with Ascot.

The Queen: fashionable and fully au fait with form

Nevertheless it was under the aegis of the Prince Regent, later George IV, that what we would recognise as ‘Royal Ascot’ really came into being. A Classic-winning owner, as he was entitled to be considering what he spent at the Tattersalls horse sales then held at Hyde Park Corner, George also had style and a sense of theatre, and this he exercised upon Ascot. He employed his architect John Nash to build an elegant Royal Stand. The lawn in front of this structure was, effectively, a forerunner of the Royal Enclosure.

In 1825 the king instituted the royal procession, now so central to the pageantry of the meeting. Four coaches travelled up the course, followed by servants on horseback, with George himself in the first coach accompanied by the Duke of Wellington. This spectacle was an instant success, a great public relations coup, although seen at such close quarters the king was said to ‘cut the lowest figure’. Nor was his behaviour endearing; observing the presence of Robert Peel, then Home Secretary, George pronounced that he would rather see a pig in a church than Peel at Ascot.

Nevertheless, the king had successfully developed – one might even say, marketed – the idea that Ascot was the place where the monarchy received the public graciously on its own land, where the royal family was on smiling display, where it could be seen enjoying itself in the same way – give or take a magnum of finest champagne – as everybody else. The carriage procession did cease briefly after the death of Prince Albert in 1861, when his wife Queen Victoria went into ‘Widow of Windsor’ mode and refused the use of Windsor Castle for the meeting. The procession was quickly revived by the then Prince of Wales, later Edward VII, whose passionate love of racehorses was a perpetual thorn in his mother’s side.

“King George IV pronounced that he would rather see a  pig in a church than Robert Peel at Ascot”

So George IV created Royal Ascot as a merry celebration of the established order, which it remains today. He also established the idea that it was as much about seeing, and being seen, as it was about sport. In this it differed from Epsom, which for all its social dimension has always kept the Derby at its heart. With Royal Ascot, despite the magnificence of the racing, it is, for the majority, the crowd itself that constitutes the real show.

With this relentless focus upon the spectators, inevitably people began to dress up to what the novelist Patrick Hamilton called ‘our old friends, the nines’. Like Queen Anne, George was not physically suited to high fashion – when he rode his horses, it was said that he put up 10st overweight – although he did give his first speech in the House of Lords wearing high pink heels. Fortunately he, and his smart set, fell under the influence of the dandy Beau Brummel, who favoured an immaculate restraint in male dress.

According to Lord Byron, what marked out Brummel’s clothes was ‘a certain exquisite propriety’: he worshipped the art of tailoring. Brummel is also credited with instituting ‘Ladies’ Day’ at Royal Ascot. The third day was, as it still is, the high point of the meeting, and Brummel suggested that only spectators in formal wear should be permitted to attend, thus making the day an occasion of high fashion and social cachet. What Brummel would have made of some of the more excitable creations now seen on Ladies’ Day, one can only imagine.

The years that took the 19th century into the 20th were a golden age for racing – and for the Prince of Wales, owner of Persimmon and Diamond Jubilee – and Royal Ascot was probably then at its smartest and most glamorous.

Princess Haya, another regular royal racegoer

In photographs it resembles nothing so much as an idyllic garden party, with men in frock coats and ‘Ascot’ cravats, and women in soft pale muslin that trails lazily across the lawns. This timeless perfection was recreated in the Ascot sequence from My Fair Lady: a few minutes of film that helped to enshrine the image of Royal Ascot as an apogee of elegance and that made the garden party atmosphere the one that the meeting still strives to recreate.

Cecil Beaton, who designed the sequence, dressed the women in white with touches of black – always a good choice – while the men are in grey, as sported nowadays by the Prince of Wales, who wears the ensemble known as ‘morning grey’. Morning coats began to supplant the more formal frock coats in the early 20th century: the change is said to date definitively from the signing of the Treaty of Versailles in 1919, to which Woodrow Wilson and Lloyd George turned up rather daringly in morning coats.

Originally these were worn for riding, in the morning. Now, of course, they constitute formal dress. Notwithstanding Prince Charles, black remains the most common choice, worn with a contrasting waistcoat, and, as stipulated in the 2012 dress code guidelines from Royal Ascot, with black shoes.

Desperately hot though morning dress must be when the sun shines, men do look good in it. It is the hat that can cause a problem, unless it fits to perfection. I once attended with a man who went through a variety of attempts to make his hired hat accommodate his ears. He rested it above them, like an upturned dish perched precariously upon the FA Cup; he clamped it down, causing the ears to fold over themselves; he tilted it to accommodate one free ear, giving him a vaguely Jack the Ripper appearance. And of course the wretched thing had to stay put.

I remember once seeing a young man remove his for a brief moment on the Royal Enclosure lawn; he was instantly pounced upon by a steward, who scolded: ‘The Queen doesn’t want to see you without your hat, sir’.

Nevertheless the problem of the top hat pales into insignificance compared with what is going on above a woman’s head. Dear lord, those hats! I have spent days at Ascot with pins through the crown that went damn near into my brain. I have watched races with my brim caught in that of the hat next to mine, like two deer locking antlers.

And the one-upmanship – or one-upwomanship – that goes on is frankly unbelievable. There are women who have been planning their outfits for the next Ascot since the end of June the previous year: it is hopeless to try and compete.

Some do look jaw-droppingly smart in their Louis Vuitton suits and £1,000 hats. Others, the ones with waxed arms and orange legs and replicas of the Olympic rings on their heads, get on the front of tomorrow’s newspapers. It is all part of the living theatre that is Royal Ascot and, in essence, it has been that way for 200 years.

After the First World War, when Ascot was suspended, elegance made a defiant comeback: George V recorded that everybody wore a ‘high hat’ like in the old days. Photographs of the 1920s, however, show some truly bizarre outfits, some of them favouring the ‘hieroglyph’ motif that became all the rage after the discovery of Tutankhamun’s tomb in 1922.

Parasols had been ditched, suntans having become fashionable, and skirts were raised to the knee, although full-length dresses did return in the 1930s.

Again there was no Ascot during World War II, but in the years afterwards women were perhaps at their most attractive, in suits with nipped-in waists and hats that looked intrinsic to their outfit, rather than the fancy-dress afterthought they often resemble today.

Queen Elizabeth II, making her first appearances as monarch, was pretty as a picture in her fitted coats and pert pillboxes. In the 1960s skirts shot up; even royalty wore them an inch or so above the knee. Nevertheless, the girl turned away from the Royal Enclosure in 1968 for wearing a trouser suit, who then re-appeared in a white dress the size of an envelope, was the headline-making exception, not the rule.

Meanwhile the outfits of Gertrude Shilling, who in 1965 was recorded as wearing a hat that measured three and a half feet, made her as much a fixture as the Gold Cup itself. Nowadays, outside the Royal Enclosure, where the new dress code sternly insists upon propriety, it is quite normal to see girls in hats the shape of football pitches or with skyscrapers growing out of their heads: Royal Ascot has become the backdrop to a peculiarly British kind of eccentricity.

Even the royal family, its junior members at least, was occasionally susceptible to excesses. In 1988 Sarah Ferguson was described in Woodrow Wyatt’s diaries as ‘walking about in a tent, a yellow one’, with ‘no stockings and flat sandals – oh my God!’, although one can undoubtedly rely upon the Duchess of Cambridge to look as smart as paint.

And it goes without saying that the Queen is above misjudgments. In 60 years she has remained a constant, in dress as in all else. Simple tailored lines, court shoes that do not sink into the turf, hats that are smart yet sensible: these are her sartorial hallmarks. The betting on what colour she will wear almost always gets it wrong. All that can be predicted is that she will be a discreetly bold figure, courteously visible to the crowd.

In the end, however – and pleasing though the Queen’s outfits are – it has somehow always been clear that they are less important to her than the sport that she is watching. In that sense she takes us directly back to Queen Anne, creator of Royal Ascot, sincere lover of racing.

Royal Enclosure dress code 2012

Dresses and skirts: modest length, falling just above the knee or longer
Straps: one inch or greater on dresses and tops
Trouser suits: matching colour
Hats: headpiece with a base of four inches (10cm) or more
Jackets and pashminas: permitted

Not allowed: fascinators, strapless dresses, off the shoulder, halter neck, spaghetti straps, straps less than one inch, bare midriffs

GENTLEMEN are required to wear either black or grey morning dress including a waistcoat and tie, a black or grey top hat and black shoes.