Re: [WSG] are underscores a problem
Drake, Ted C. wrote: But then I thought I should check to see if there would be any problems using an underscore in an id or class. Is it one of the legal characters? Don't know about 'legal', but I have had problems with certain browsers in the past ignoring css rules applied to classes and/or ids with underscores in their names. Early version/s of Safari come to mind; there may be others - and the issue may have been fixed in later releases. If I sound vague, it's because I fixed the problem by never again using underscores in id/class names, so I haven't tested for it lately... HTH N ___ Omnivision. Websight. http://www.omnivision.com.au/ ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list & getting help **
Re: [WSG] are underscores a problem
That said, I was asked if we could modify some id and class names to go from nav1sub1 to nav1_sub1 . I told them my preference would be nav1- sub1. But then I thought I should check to see if there would be any problems using an underscore in an id or class. Is it one of the legal characters? This topic came up a month ago. Read the archived thread for more info. Underscores were illegal in CSS 2.0, but "legalized" in 2.1 since every browser except Netscape 4 violated that rule. Since 2.1 is a refinement of 2.0, 2.1 completely replaces 2.0 -- that is, there is no such thing as conforming to CSS 2.0, like you could conform to both HTML 4 and XHTML 1. Hyphens are not forbidden, but are frowned on since they caused minor problems with some versions of Javascript interacting with IDs. I don't remember the specifics. If you need to support Netscape Navigator 4.x, do not put underscores in your IDs or class names. -- Ben Curtis : webwright bivia : a personal web studio http://www.bivia.com v: (818) 507-6613 ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list & getting help **
Re: [WSG] are underscores a problem
Does that mean the best way to go fro ID, Class Names, Variables, etc... is interCaps (also known as CamelCase or lowerCamelCase) ? http://en.wikipedia.org/wiki/CamelCase R - Original Message - From: "Ben Curtis" <[EMAIL PROTECTED]> To: Sent: Friday, July 08, 2005 9:07 AM Subject: Re: [WSG] are underscores a problem That said, I was asked if we could modify some id and class names to go from nav1sub1 to nav1_sub1 . I told them my preference would be nav1- sub1. But then I thought I should check to see if there would be any problems using an underscore in an id or class. Is it one of the legal characters? This topic came up a month ago. Read the archived thread for more info. Underscores were illegal in CSS 2.0, but "legalized" in 2.1 since every browser except Netscape 4 violated that rule. Since 2.1 is a refinement of 2.0, 2.1 completely replaces 2.0 -- that is, there is no such thing as conforming to CSS 2.0, like you could conform to both HTML 4 and XHTML 1. Hyphens are not forbidden, but are frowned on since they caused minor problems with some versions of Javascript interacting with IDs. I don't remember the specifics. If you need to support Netscape Navigator 4.x, do not put underscores in your IDs or class names. -- Ben Curtis : webwright bivia : a personal web studio http://www.bivia.com v: (818) 507-6613 ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list & getting help ** ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list & getting help **
Re: [WSG] are underscores a problem
Richard Czeiger wrote: Does that mean the best way to go fro ID, Class Names, Variables, etc... is interCaps (also known as CamelCase or lowerCamelCase) ? http://en.wikipedia.org/wiki/CamelCase R I've adopted lowerCamelCase for nearly everything of my programming guideline except when dealing with databases (in which I use all lower with typical underscores) and class names in Java. As programmed other languages before CSS. Plus lowerCamelCase makes it easier to read than a something named with a ton of underscores. An example from today's work (non-CSS): errorHandler.invalidPropertyName vs error_handler.invalid_property_name Best, .Peter -- Peter J. Farrell :: Maestro Publishing blog:: http://blog.maestropublishing.com email :: [EMAIL PROTECTED] Create boilerplate beans! Check out the Mach-II Bean Creator - free download. http://blog.maestropublishing.com/mach-ii_beaner.htm ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list & getting help **
RE: [WSG] are underscores a problem
I've been using the dash and period in ID names a lot recently (part of an unobtrusive DOM scripting set of functions I've been developing) and not found any problems yet in any of the Win browsers. Whether IDs formatted like this "functionName.-fe-4r-6s-ef-s5-ef.2000" will work in older browsers or different operating systems I'm kind of crossing my fingers about! Chris -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter J. Farrell Sent: 08 July 2005 01:25 To: wsg@webstandardsgroup.org Subject: Re: [WSG] are underscores a problem Richard Czeiger wrote: > Does that mean the best way to go fro ID, Class Names, Variables, > etc... is interCaps (also known as CamelCase or lowerCamelCase) ? > > http://en.wikipedia.org/wiki/CamelCase > > R I've adopted lowerCamelCase for nearly everything of my programming guideline except when dealing with databases (in which I use all lower with typical underscores) and class names in Java. As programmed other languages before CSS. Plus lowerCamelCase makes it easier to read than a something named with a ton of underscores. An example from today's work (non-CSS): errorHandler.invalidPropertyName vs error_handler.invalid_property_name Best, .Peter -- Peter J. Farrell :: Maestro Publishing blog:: http://blog.maestropublishing.com email :: [EMAIL PROTECTED] Create boilerplate beans! Check out the Mach-II Bean Creator - free download. http://blog.maestropublishing.com/mach-ii_beaner.htm ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list & getting help ** ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list & getting help **
Re: [WSG] are underscores a problem
On Jul 8, 2005, at 1:37 AM, Chris Taylor wrote: I've been using the dash and period in ID names a lot recently (part of an unobtrusive DOM scripting set of functions I've been developing) and not found any problems yet in any of the Win browsers. Whether IDs formatted like this "functionName.-fe-4r-6s-ef-s5-ef.2000" will work in older browsers or different operating systems I'm kind of crossing my fingers about! By "not found any problems" I assume you mean that these IDs are only referenced by your script, and not the CSS. JS only requires that IDs are strings. Trying to assign styles to your elements via CSS would be problematic, since each period would be interpreted as a class name indicator, and your middle classname starts with a hyphen (an illegal start). But if you are only accessing the info via JS, then it should be fine. Richard Czeiger wrote: Does that mean the best way to go fro ID, Class Names, Variables, etc... is interCaps (also known as CamelCase or lowerCamelCase) ? Some people believe so. I do. The problem that you'll run into is that IDs and class names are case sensitive with an XHTML doctype (and always case sensitive when accessed via the DOM), and so using compound words can result in particularly difficult bugs to find (e.g., what that backGroundDIV or BackGroundDiv or backgroundDiv or...?). Best to avoid compound words, I think (e.g., replace with bgContent). -- Ben Curtis : webwright bivia : a personal web studio http://www.bivia.com v: (818) 507-6613 ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list & getting help **
RE: [WSG] are underscores a problem
On Jul 8, 2005, at 1:37 AM, Chris Taylor wrote: > I've been using the dash and period in ID names a lot recently (part > of an unobtrusive DOM scripting set of functions I've been developing) > and not found any problems yet in any of the Win browsers. Whether IDs > formatted like this "functionName.-fe-4r-6s-ef-s5-ef.2000" will work > in older browsers or different operating systems I'm kind of crossing > my fingers about! Ben Curtis replied: > By "not found any problems" I assume you mean that these IDs are only > referenced by your script, and not the CSS. JS only requires that IDs are > strings. Trying to assign styles to your elements via CSS would be > > problematic, since each period would be interpreted as a class name > indicator, and your middle classname starts with a hyphen (an illegal > start). But if you are only accessing the info via JS, then it should be > fine. Absolutely, and although it would be better to be able to use these IDs for CSS, at the moment it's not essential. Actually, I could have modified the IDs so they didn't have dashes in, but my JavaScript skills gave up at that point. Chris ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list & getting help **