HTML属性值的最大长度

HTML属性值的最大长度

本文介绍了HTML属性值的最大长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么知道元素的属性值的最大长度是多少?

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

例如

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

此div的ID属性以及任何元素的其他任何属性的最大允许长度是多少?

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

推荐答案

根据 HTML 4的SGML声明,限制为65536个字符:

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 --

LITLEN限制可以在单个属性值文字中出现的字符数,而ATTSPLEN限制在标签中出现的所有属性值规格的所有长度的总和.

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.

显然,该限制以前在HTML 2 ,当时人们在1995年抱怨.

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

这篇关于HTML属性值的最大长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 06:19