kecoak
asked on
HTML Naming convention
Is there a best practice HTML Naming convention that I can use to name the table, buttons, div, etc2?
There is no naming convention as such, although what ryancys suggests is often seen.
DIV and TABLE elements don't even have a name attribute (but you can use the ID) attribute.
The HTML Spec has this rule:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
I personally don't usually prefix names as they deliver little benefit. Radio buttons could easily be refactored into a drop-down list, I'd prefer not to have the obsticle of having to rename the request parameter names on the server in the process.
When naming elements, try to capture function rather than appearance. E.g., one should have "error" and "success" instead of "redCross" and "greenTick".
--
Lee
DIV and TABLE elements don't even have a name attribute (but you can use the ID) attribute.
The HTML Spec has this rule:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
I personally don't usually prefix names as they deliver little benefit. Radio buttons could easily be refactored into a drop-down list, I'd prefer not to have the obsticle of having to rename the request parameter names on the server in the process.
When naming elements, try to capture function rather than appearance. E.g., one should have "error" and "success" instead of "redCross" and "greenTick".
--
Lee
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
tblXXX, divXXX, btnXXX, cmdXXX, chkXXX, optXXX
try use a standard name in front of your element, so that it can be recognize easily.