<optgroup label ='-------'> </ optgroup>给出了xhtml验证错误

use*_*307 5 html css optgroup

Error: End tag for 'optgroup' which is not finished. You have probably failed to 
include a required child element. Hence the parent element is "not finished",
 not complete. 
Run Code Online (Sandbox Code Playgroud)

我想在select选项中实现类似的功能.

USA
UK
--
Afghanistan
Run Code Online (Sandbox Code Playgroud)

我想把几个重要国家放在首位,然后是一个不可选择的分隔符,然后排序其余国家的列表.

我把这个分隔符用空'optgroup'.虽然它在所有浏览器中都运行良好,但我得到验证错误.

可能有哪些其他方法来实现这一点?

Poi*_*nty 5

与@ZippyV编写的类似,您可以使用a <option>并将其禁用:

<option disabled='disabled'>--</option>
Run Code Online (Sandbox Code Playgroud)

这是不可选择的.如果是我,我会使用m-dash而不是两个连字符:

<option disabled='disabled'>&mdash;</option>
Run Code Online (Sandbox Code Playgroud)