Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Max length of an HTML attribute value

Tags:

html

How would I know what the maximum length of an element's attribute value is?

e.g.

<div id="value1..."></div>

What's the maximum allowable length for ID attribute of this div and any other attributes of any elements?

like image 523
mars-o Avatar asked May 02 '10 04:05

mars-o


People also ask

What is Max length attribute HTML?

The maxlength attribute defines the maximum number of characters (as UTF-16 code units) the user can enter into an <input> or <textarea> . This must be an integer value 0 or higher. If no maxlength is specified, or an invalid value is specified, the input or textarea has no maximum length.

How long can an HTML id be?

This limit is usually between 8 and 13 characters, depending on how long I've been working and if the names make sense in the context of the element.

What is attribute length?

The length attribute has a numeric value equal to the number of bytes occupied by the data that is named by the symbol specified in the attribute reference.


2 Answers

According to the SGML Declaration of HTML 4, the limit could be 65536 characters:

ATTSPLEN 65536   -- These are the largest values --
LITLEN   65536   -- permitted in the declaration --
NAMELEN  65536   -- Avoid fixed limits in actual --
PILEN    65536   -- implementations of HTML UA's --

The LITLEN limits the number of characters which can appear in a single attribute value literal and the ATTSPLEN limits the sum of all lengths of all attribute value specifications which appear in a tag.

Apparently, the limits used to be much lower in HTML 2, and people were complaining back then in 1995.

like image 123
Daniel Vassallo Avatar answered Sep 25 '22 01:09

Daniel Vassallo


According to this page, technically unlimited. An actual test in various browsers will show their limits but my guess is the limit would be unreasonably long.

like image 36
Trey Hunner Avatar answered Sep 25 '22 01:09

Trey Hunner