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
  • Not to be outdone, Google recently introduced Gemini CLI - a type of AI agent similar to Codex or Claude Code.

    What’s notable is that they offer up to... 1000 queries for free each day. That’s quite a lot. Additionally, they have open-sourced this project to ensure transparency, learning, and research 🤓

    » Read more
  • There’s another tool to help quickly search command history: atuinsh/atuin.

    What’s interesting is that it uses SQLite for storage. It also provides the feature of completely synchronizing (encrypting) history between machines. How cool is that 🤓

    » Read more
  • I am really impressed with the gemma-3n-E4B model from Google. This is one of the promising models that aims to bring large language models to run on mobile devices or the web or embedded...

    It feels like it understands the prompts better, because I’ve tried many low-parameter models that often overlook my prompts. For example, when I say, "Just return the answer, no need for further explanation," many still tend to add introductory phrases or explanations... but with gemma-3n, the responses are very much to the point.

    » 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

The secret stack of Blog

As a developer, are you curious about the technology secrets or the technical debts of this blog? All secrets will be revealed in the article below. What are you waiting for, click now!

As a developer, are you curious about the technology secrets or the technical debts of this blog? All secrets will be revealed in the article below. What are you waiting for, 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