Length Limits You Should Know as a Web Developer

Cygra
3 min readMay 4, 2022
Photo by Richy Great on Unsplash

In code, the title of a web page is determined by the title tag which appears on the top of a html document inside the head tag. Theoretically, the content of the title tag can be whatever long as you fill it.

However, there are limits elsewhere.

When your web page is displayed on SERP(Search Engine Results Page), the title will be trimmed to ~60 characters. The longer part is replaced with dots (…).

SERP(Search Engine Results Page)
SERP(Search Engine Results Page)

And the tab of a browser. As for Chrome, up to about 22 characters can be displayed on the tab directly. Starting with Google Chrome version 78, one of the new features enabled by default are Tab Hover Cards. The cards automatically pop up when you hover your mouse over an individual tab. The card will display the title and URL of the page. It has similar behavior with SERP (title trimmed to ~60 characters, longer part replaces with dots).

So, a good practice is to keep the title about 60 characters long, so the title can be displayed without trimmed. This can also provide web users with a concise description of a web page’s content and allows search engine algorithms to determine whether the site is relevant to the inputted search term or keyword.

The other length limit you should pay attention to is the url length of a GET request. A GET request encode all data into the URL as query string parameters.

The RFC suggest a limit of 8000 characters(https://www.rfc-editor.org/rfc/rfc7230#section-3.1.1) but the reality is a bit different.

Chromium(Chrome / Edge) has a limt of 2Mb which is long enough to cover a novel. The definition is here:

Gecko limits at 1Mb, the code is at:

This is the situation of the browser side. What about the server?

For nginx, URL shares the buffer with request header. The default size of the buffer is 8Kb. This size can be modified with large_client_header_buffers.

Things are similar on Node.js. URL, status message, request headers share a buffer size of 16Kb. The code is at:

Consider of Liebig’s law of the minimum, it’s safe to keep the URL not exceed 8k to be compatible with every part of a HTTP request.

--

--

Cygra
0 Followers

Web Developer in Tiktok. Write about git, js, interview, etc.