The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

If I have ids gathered from a db (typically from an int, auto_increment column), I must add a letter before it in my html to make it happy, then I must remove the added letter for all that is ajax? Are you sure that it's best practice? Are there no exception?

If I have ids gathered from a db (typically from an int, auto_increment column), I must add a letter before it in my html to make it happy, then I must remove the added letter for all that is ajax? Are you sure that it's best practice? Are there no exception?

The reason HTML4 says this is because it uses the same datatypes as SGML, and SGML has these seemingly arbitrary restrictions. I don't know why SGML has these restrictions.

In HTML5 the requirement is that the id is not the empty string and that it doesn't contain whitespace. Anything else goes (like e.g. id="1"). Note, however, that Selectors doesn't allow #id and .class selectors to start with a number, so you'd have to use escapes as in #\0031 instead of #1.

SGML has these seemingly arbitrary restrictions. I don't know why SGML has these restrictions.

In HTML5 the requirement is that the id is not the empty string and that it doesn't contain whitespace.

So you're badmouthing SGML for 'arbitrary' restrictions and then you're specifying arbitrary restrictions?

It's quite common in many areas that identifiers aren't allowed to start with a digit. Most programming languages, for instance, don't allow variable names like 3p. I can't see how this SGML restriction could be a major obstacle.

You could use the rel or title attribute then use a attribute selector. I think I need a shower though after suggesting that. I find it difficult to believe that prefixing the id with a string would be difficult to manipulate as long as the string was consistent. Also, prefixing a string avoids conflicts. For example, if a blog and news item are on the same page and both have a primary key of 1 then you run into a conflict when using a id unless you use a prefix.

So you're badmouthing SGML for 'arbitrary' restrictions and then you're specifying arbitrary restrictions?

HTML5's restrictions aren't arbitrary. It can't be the empty string because the empty string can't be referenced by various means that reference element(s) by ID. It can't contain whitespace because there are attributes that reference elements by their ID, splitting the attribute's value on whitespace (e.g. <td headers>).

Originally Posted by AutisticCuckoo

It's quite common in many areas that identifiers aren't allowed to start with a digit.

Indeed.

Originally Posted by AutisticCuckoo

Most programming languages, for instance, don't allow variable names like 3p. I can't see how this SGML restriction could be a major obstacle.

It can't be the empty string because the empty string can't be referenced by various means that reference element(s) by ID.

Then you could fix those means so that they'd accept an empty string.

Originally Posted by zcorpan

It can't contain whitespace because there are attributes that reference elements by their ID, splitting the attribute's value on whitespace (e.g. <td headers>).

Then choose a better way to specify multiple IDs then to separate them by an arbitrary character.

I'm not suggesting that you change these things, of course. I'm just pointing out that the restrictions imposed are completely arbitrary because of flaws in the design. Just like the restrictions in SGML.

Tommy, I'm sorry if this is totally off topic and irrelevant, but you should really change your approach when answering questions. I also find you get worked up easily and you fire rolleyes too quickly. Next time I'll report your posts for harshness. Please work on putting a nice mood around the forums.