Puzzle: What is Mozilla/5.0? Why does every browser have this string in its User-Agent?

Puzzle: What is Mozilla/5.0? Why does every browser have this string in its User-Agent?

Daily short news for you
  • Previously, there was a mention of openai/codex - a type of agent that runs conveniently in the Terminal from OpenAI, especially since it is open source and they have now added support for other providers instead of just using the chatgpt model as before.

    Recently, Anthropic also introduced Claude Code which is quite similar to Codex, except it is not open source and you are required to use their API. Since I don't have money to experiment, I've only heard that people in the programming community praise it a lot, and it might even be better than Cursor. On the flip side, there's the risk of burning a hole in your wallet at any moment 😨

    » Read more
  • For a long time, I have been thinking about how to increase brand presence, as well as users for the blog. After much contemplation, it seems the only way is to share on social media or hope they seek it out, until...

    Wearing this shirt means no more worries about traffic jams, the more crowded it gets, the more fun it is because hundreds of eyes are watching 🤓

    (It really works, you know 🤭)

    » Read more
  • A cycle of developing many projects is quite interesting. Summarized in 3 steps: See something complex -> Simplify it -> Add features until it becomes complex again... -> Back to a new loop.

    Why is that? Let me give you 2 examples to illustrate.

    Markdown was created with the aim of producing a plain text format that is "easy to write, easy to read, and easy to convert into something like HTML." At that time, no one had the patience to sit and write while also adding formatting for how the text displayed on the web. Yet now, people are "stuffing" or creating variations based on markdown to add so many new formats that… they can’t even remember all the syntax.

    React is also an example. Since the time of PHP, there has been a desire to create something that clearly separates the user interface from the core logic processing of applications into two distinct parts for better readability and writing. The result is that UI/UX libraries have developed very robustly, providing excellent user interaction, while the application logic resides on a separate server. The duo of Front-end and Back-end emerged from this, with the indispensable REST API waiter. Yet now, React doesn’t look much different from PHP, leading to Vue, Svelte... all converging back to a single point.

    However, the loop is not bad; on the contrary, this loop is more about evolution than "regression." Sometimes, it creates something good from something old, and people rely on that goodness to continue the loop. In other words, it’s about distilling the essence little by little 😁

    » Read more

The Issue

One fine day while researching the User-Agent (UA) string of popular web browsers, I noticed a common pattern among them. Apart from the unique strings that identify the browsers like Chrome/43.0.2357.65, Firefox/40.0, MSIE 9.0, almost all of them had a string called Mozilla/5.0 or sometimes WebKit. What are these strings and why do they appear in the User-Agent? I delved into the history and discovered some interesting facts about this phenomenon.

History of the UA string

NCSA Mosaic was the world's first web browser, and when it was released, it identified itself as NCSA_Mosaic/2.0 (Windows 3.1) through the UA string that we still know today. Mosaic was the first browser to display images along with text :D.

Then a new web browser called "Mozilla" emerged, which stood for "Mosaic Killer." However, they realized that the name wasn't very interesting, so Mozilla was changed to Netscape, and Netscape identified itself as Mozilla/1.0 (Win3.1).

Netscape introduced frames, which became popular among the Internet community, but Mosaic did not support frames. Therefore, developers had to check the browser type to send frames. If the browser was Netscape, frames were sent; otherwise, they weren't :D.

Netscape then mocked Microsoft (MS), calling Windows "poorly debugged device drivers," which made Microsoft angry. As a result, Microsoft created its own web browser called Internet Explorer (IE) with the hope of becoming a "Netscape Killer."

Of course, IE had to support frames, but it wasn't Mozilla, so it didn't provide frames by default for web administrators. Microsoft was impatient and didn't want to wait for web admins to figure out IE. Therefore, IE declared itself "Mozilla-compatible" and started impersonating Netscape, identifying itself as Mozilla/1.22 (compatible; MSIE 2.0; Windows 95). Immediately, IE received frames, which pleased MS but confused web administrators. MS bundled IE with Windows, making it popular and better than Netscape. The first browser war erupted everywhere.

As predicted by MS, Netscape was defeated. However, Netscape was reborn as Mozilla, and Mozilla developed Gecko, identifying itself as Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv: 1.1) Gecko/20020826. Gecko was the best rendering engine at the time.

Mozilla further evolved into Firefox and identified itself as Mozilla/5.0 (Windows; U; Windows NT 5.1; sv-SE; rv: 1.7.5) Gecko/20041108 Firefox/1.0. Firefox excelled as a web browser. Gecko began to flourish, and other browsers were created using its code. They called themselves names like Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv: 1.7.2) Gecko/20040825 Camino/0.8.1 and Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv: 1.8.1.8) Gecko/20071008 SeaMonkey/1.0. They all pretended to be Mozilla and were powered by Gecko.

Gecko was an excellent rendering engine, while IE was the opposite, causing web administrators to scramble to differentiate code for different browsers. Other browsers struggled to compete with Gecko.

Linux enthusiasts noticed this and couldn't sit still, so they created Konqueror with the KHTML engine, considering it "as good as" Gecko, but it wasn't Gecko, so it didn't return Gecko code. Therefore, Konqueror declared itself "KHTML-compatible" to obtain Gecko code and identified itself as Mozilla/5.0 (compatible; Konqueror/3.2; FreeBSD) (KHTML, like Gecko).

Then came Opera, saying, "We should let users decide which browser they prefer." So Opera allowed users to choose UA strings like Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; vi) Opera 9.51 or Mozilla/5.0 (Windows NT 6.0; U; en; rv: 1.8.1) Gecko/20061208 Firefox/2.0.0 Opera 9.51 or Opera/9.51 (Windows NT 5.1; U; en).

Apple built Safari using KHTML but added many features, so the project split and called it WebKit. However, they wanted to use code written for KHTML. Therefore, Safari identified itself as Mozilla/5.0 (Macintosh; U; PPC Mac OS X; de-de) AppleWebKit/85.7 (KHTML, like Gecko) Safari/85.5.

Once again, MS brought back Internet Explorer with a new version. They called it Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) and displayed Gecko code very well, but only when web administrators commanded it to do so.

Finally, Google built Chrome using WebKit just like Safari, and of course, Chrome wanted websites built for Safari, so it pretended to be Safari. Chrome identified itself as Mozilla/5.0 (Windows; U; Windows NT 5.1; vi-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13.

Subsequently, browsers, regardless of how they were born, "tried" to race to become "like" the browsers already on the Internet market.

So far, let's summarize what the browser war has left us with. Chrome used WebKit and pretended to be Safari, while WebKit pretended to be KHTML, and KHTML pretended to be Gecko. In the end, all browsers pretend to be Mozilla!!!

Conclusion

The browser community has gone through many changes, resulting in a chaotic UA string as we see today. In 2020, Chrome announced that it would remove the UA string from the browser, but it seems that it hasn't been fully implemented yet. In reality, developers are still writing code to be compatible with Mozilla/5.0 :D.

References:

Premium
Hello

5 profound lessons

Every product comes with stories. The success of others is an inspiration for many to follow. 5 lessons learned have changed me forever. How about you? Click now!

Every product comes with stories. The success of others is an inspiration for many to follow. 5 lessons learned have changed me forever. How about you? Click now!

View all

Subscribe to receive new article notifications

or
* The summary newsletter is sent every 1-2 weeks, cancel anytime.

Comments (2)

Leave a comment...
Avatar
Hương Trịnh2 years ago

Bỏ UA đi thì sao mà detect đc browser nữa nhỉ? Kb có phát minh gì mới sao?

Reply
Avatar
Xuân Hoài Tống2 years ago

Mình cũng đoán là chắc có công nghệ gì đó thay thế

Avatar
Vũ Mạnh Đức3 years ago

Oh thì ra là vậy thật thú vị h mới hiểu :D

Reply
Avatar
Xuân Hoài Tống3 years ago

:D hay mà bạn