Jump to content

[SOLVED] Valid name, id, and class attributes in XHTML?


AmandaF

Recommended Posts

I'm writing a php script that involves generating an input element for an xhtml form, and I wanted it to throw an error if the arguments for the name, id, or class attribute of the element isn't valid for xhtml 1.0 strict.  The official specification (http://www.w3.org/TR/xhtml1/), as far as I can tell, only gives a definition for ID fragments, not the full id attribute.  Unofficial sites (blogs, forums, etc) seem to say that IDs and names are a letter followed by one or more letters, numbers, hyphens, underscores, colons and periods.  (i.e. /[a-z0-9][-a-z0-9_:.]*/i)

 

If that's the case, doesn't that mean the syntax for making a name attribute an array in php is invalid?  (e.g. name="foo[]" is invalid).  For that matter, wouldn't that make fragments invalid?  (e.g. <a name="#foo">)

Did a bit more research and it looks like only ID attributes are limited the way I described.  Name attributes can be any valid xhtml characters (so basically everything except < > and &).

 

I'm going to mark this thread as solved, but if anyone has anything to add, please post a reply.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.