CodeIgniter Forums
what name spacing to use for div id's and classes? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: what name spacing to use for div id's and classes? (/showthread.php?tid=52719)

Pages: 1 2


what name spacing to use for div id's and classes? - El Forum - 06-24-2012

[eluser]CroNiX[/eluser]
But to the original posters question, it doesn't matter how you name your html attributes, just as long as they are valid and they makes sense to your application and maintaining it.


what name spacing to use for div id's and classes? - El Forum - 06-24-2012

[eluser]jmadsen[/eluser]
Yeah, I think something is backwards here.

Working with "data" attributes, for example , standard naming is:

"data-mytable_id"

No hyphens in variable names; use underscores. Hyphens are fine in class & id & attribute names.




what name spacing to use for div id's and classes? - El Forum - 06-25-2012

[eluser]webmastergrumpy[/eluser]
No clear answer yet.

JQuery uses - in class names

so id's with underscore and class names with - ?


what name spacing to use for div id's and classes? - El Forum - 06-25-2012

[eluser]LuckyFella73[/eluser]
Aken posted:
Quote:This is backwards. Javascript prefers underscores.

The most widely accepted, unofficial standard is to use underscores in IDs, and hyphens in class names.

http://stackoverflow.com/questions/1696864/naming-class-and-id-html-attributes-dashes-vs-underlines

Beyond that, the naming conventions are your own personal preference.

Isn't that clear? I prefer to name my classes and ids the same way and
never had a problem using javascript yet (caused by "-" or "_").