Quote:
Originally Posted by Philip M
You tell me something. But I have never had any occasion to use an option id.
|
Well, now you can use them to your heart's content.
Quote:
Originally Posted by Philip M
But surely an id may not start with a number?
From the HTML 4 specification: ID and NAME tokens must begin with a letter ([A-Za-z])
|
In HTML4 and XHTML 1/1.1, there is that restriction, yes. This is a legacy, SGML-based restriction though.
I can't find anything in the HTML5 specs (WHATWG or W3C) or the spec that those two link to relating to IDs (the WHATWG's DOM Living Standard spec) that indicates that this restriction persists.
Quote:
Originally Posted by Philip M
I tested your script and - amazingly it works in HTML4 (no !DOCTYPE)! Why is that? 
|
Well, the
id attribute for
option elements
is defined in the HTML4 spec, so it's not really surprising.
Quote:
Originally Posted by Philip M
Could you devise an example where an option id is really useful?
|
No, not really, unless maybe it works better than Logical Ali's solution in the situation that Old Pedant mentioned (compatibility with old versions of Firefox). I never said that it was particularly useful, just that it wasn't disallowed.
Thankfully, there's no need to remember which elements
id attributes are allowed on anymore; HTML5 simplifies things by permitting IDs for everything instead of carving out exceptions like HTML4 did.