选择选项值可以是不同的类型? [英] Can the select option value be of different types?
问题描述
示例
我想知道选择选项值的最佳做法。
< select name =select>
< option value =0-9>样本< / option>
< option value =a-z>样本< / option>
< option value =this-is-sample-value>样本< / option>
< option value =this_is_sample_value>样本< / option>
< option value =this& is | sample ** value>样本< / option>
< / select>
我在这里有点困惑。是否选择值与输入文本
和 textarea
可以在option元素的value属性中设置的数据类型没有限制。当然,HTML中具有特殊含义的字符需要由适当的实体( 该属性被定义为包含CDATA : - http://www.w3.org/TR/html4/interact/forms.html#h-17.6 CDATA是 用户代理可能会忽略CDATA 对于CDATA $ b $的某些HTML 4属性b属性值,则规范 - http:// www.w3.org/TR/html4/types.html#type-cdata 规范没有对选项元素的value属性施加额外的限制。 I want to know what is good practice for select option values. Example I'm a little bit confused here. Is the select value same like There are no limits real to the type of data that can be set in the value attribute of the option element. Characters with special meaning in HTML do, of course, need to be represented by the appropriate entities ( The attribute is defined as containing CDATA: — http://www.w3.org/TR/html4/interact/forms.html#h-17.6 CDATA is a sequence of characters from
the document character set and may
include character entities. User
agents should interpret attribute
values as follows: User agents may ignore leading and
trailing white space in CDATA
attribute values (e.g., " myval "
may be interpreted as "myval").
Authors should not declare attribute
values with leading or trailing white
space. For some HTML 4 attributes with CDATA
attribute values, the specification
imposes further constraints on the set
of legal values for the attribute that
may not be expressed by the DTD. — http://www.w3.org/TR/html4/types.html#type-cdata The specification doesn't impose additional limits for the option element's value attribute. 这篇关于选择选项值可以是不同的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!&
)来表示
<!ELEMENT OPTION - O(#PCDATA) - 可选择的选项 - >
<!ATTLIST OPTION
%attrs; - %coreattrs,%i18n,%events - 选择
(选择)#IMPLIED
禁用(禁用)#IMPLIED - 在此上下文中不可用 -
标签%Text; #IMPLIED - 用于分层菜单 -
值CDATA #IMPLIED - 默认为元素内容 -
>
文档字符集中的一系列字符,可能
包含字符实体。用户
代理应该如下解释属性
的值:
$ b
属性值(例如,myval
可能被解释为myval)中的前导和
尾随空白。
作者不应该使用前导或后缀为白色的
空间来声明属性
值。
会对
不能由DTD表示的属性的合法值的集合
施加进一步限制。
<select name="select">
<option value="0-9">Sample</option>
<option value="a-z">Sample</option>
<option value="this is sample value">Sample</option>
<option value="this-is-sample-value">Sample</option>
<option value="this_is_sample_value">Sample</option>
<option value="this & is | sample ** value">Sample</option>
</select>
input text
and textarea
&
as &
for example (although the one in the question meets the "followed by a space character" exception to the rule)).<!ELEMENT OPTION - O (#PCDATA) -- selectable choice -->
<!ATTLIST OPTION
%attrs; -- %coreattrs, %i18n, %events --
selected (selected) #IMPLIED
disabled (disabled) #IMPLIED -- unavailable in this context --
label %Text; #IMPLIED -- for use in hierarchical menus --
value CDATA #IMPLIED -- defaults to element content --
>