我只是想知道什麼有效的字符可以作爲一個<option>
有效字符
值即是這有效嗎?
<select>
<option value='0dbl,2sgl'>0 Double and 2 Singles</option>
<option value='1dbl,0sgl'>1 Double and 0 Singles</option>
</select>
我只是想知道什麼有效的字符可以作爲一個<option>
有效字符
值即是這有效嗎?
<select>
<option value='0dbl,2sgl'>0 Double and 2 Singles</option>
<option value='1dbl,0sgl'>1 Double and 0 Singles</option>
</select>
是的,這是完全有效的。 See the specification:它說的value
的內容應該是CDATA
,其中幾乎一切有效,有以下注意事項:
對於HTML4:
OPTION Attribute definitions
selected [CI]
When set, this boolean attribute specifies that this option is pre-selected.
value = cdata [CS]
This attribute specifies the initial value of the control. If this attribute is not set, the initial value is set to the contents of the OPTION element.
label = text [CS]
This attribute allows authors to specify a shorter label for an option than the content of the OPTION element. When specified, user agents should use the value of this attribute rather than the content of the OPTION element as the option label.
來源:http://www.w3.org/TR/html401/interact/forms.html#h-17.6
所以我們去CDATA的定義:
CDATA是一個字符從 文件序列字符集並可能包含字符entiti ES。用戶 劑應如下解釋屬性 值:
對於CDATA 屬性值的一些HTML 4個屬性,說明書 強加合法值的設定 爲屬性進一步約束 可以不被DTD來表示。
來源:http://www.w3.org/TR/html401/types.html#type-cdata
由於沒有約束指出的,value
有效的內容必須正確轉義實體,正確定義的實體,並且是文檔的編碼範圍之內。
太棒了。謝謝。 – silent1mezzo 2011-05-19 20:01:06