HTML: ID naming convention

if you have an ajaxy library that can edit divs in-place:

<div id="story.1234">
    <div id="story.1234:title">the title</div>
</div>
<div id="story.1235">
    <div id="story.1235:title">the second title</div>
</div>

The naming convention is:

type.id:property

aka:

table_name.id:column_name

More or less.

You could even stack the objects.

<div id="type1.id.type2.id:property">foobar</div>

The id tells you how to traverse the object path to alter the appropriate property.

If you need a composite key for an id, then: type1.id-id-id:property.

If one of the fields is not numeric and contains a dash, then, perhaps encode the value into a string.

This syntax is legit HTML, and I think it was intended to be used this way.

However, a few google searches only turned up (for me) one example of the above. Asp.Net control ID and HTML. So, the custom controls in ASP.NET are using a similar long naming convention to map from HTML controls to server-side code that handles the control.

(The other discussion was mostly HTML coders debating whether to use presentational or semantic names.)

Now, the trick here to using these long IDs is to pass the long ID back to the server. The server decodes it, and then uses the information to update the appropriate chunk of data.

Likewise, on the server side, when a web page exports html, or a web service exports objects, it should export these long IDs instead of the traditional short IDs used in the table.

Code's not written, but, maybe it will be soon.