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">)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.