Length Limits You Should Know as a Web Developer

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)

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.

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Deploy a NextJs app to DigitalOcean using Github Actions and Docker

How to Decrypt a ZIP File in Node.JS

How to Secure Keys in Reactjs?

Validate all Facebook URL schemes

React_part I

How to Geocode a Street Address in Node.JS

10 interesting things about Reactjs

Implementing Graphs with JavaScript

A Directed Graph

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cygra

Cygra

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

More from Medium

Mistakes I have made as a JS noob developer

ReactJS And AngularJS: Which One To Choose In 2022!

ReactJS vs AngularJS — Verzeo

Object vs JSON

Top 10 Must Know JavaScript Functions