rlm2008 — 2011-04-01T15:10:44-04:00 — #1
I'm in the process of updating/unobtrusifying my gallery website.
The html for the thumbnail links is generated in PHP from a database.
I need to pass an identifier to popup.php and wondered if it was 'a okay' to add a 'picId' property to my html as follows and then construct a URL something along the lines of 'popup.php?imageId=' + imgLink[x].getAttribute('picId').
<a href="ASSETS/Hires/Torosaurus.jpg" [B]picId="1"[/B]>
<img src="ASSETS/Thumbs/Torosaurus.jpg" alt="Torosaurus"
Is the above idea a bad idea semantically or just a bad idea fullstop.
markbrown4 — 2011-04-01T17:27:38-04:00 — #2
I don't think classes and id's are meant to start with numbers - could be for supporting older browsers, or they may not be styled correctly with CSS selectors.
HTML5 has introduced the idea of data attributes which could also be used when you need more than the id / class allow.
John Resig - HTML 5 data- Attributes
Basically it's ok to add any attribute for attaching extra data to an element by prefixing with 'data-'
<a href="ASSETS/Hires/Torosaurus.jpg" data-id="1">
rlm2008 — 2011-04-01T19:22:41-04:00 — #3
That's spot on Mark. Thanks a lot:)