Monday, February 26, 2007

Valid characters for ID and NAME attributes

The W3C defines ID and NAME requirement as -

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

So colons is a valid character used inside an ID.

Why do I mention this? We want to find a way to specify unique ID names, even we do not know what the outside HTML will look like. Say we are building a component containing some HTMLs. This component is going to be embeded into other pages. We may consider add a prefix for example

wasterpack::id_error

is a valid ID.

No comments: