I would like to use either Camel Case (e.g. #wrapperLessFooter) or Pascal Case (e.g. #WrapperLessFooter) for an ID Selector.
Is this possible?
TomTees
I would like to use either Camel Case (e.g. #wrapperLessFooter) or Pascal Case (e.g. #WrapperLessFooter) for an ID Selector.
Is this possible?
TomTees
As was mentioned if you are using XHTML or XML which is case sensitive then obviously CSS effectively becomes case sensitive for the selectors also because it must match a case sensitive markup language.
HTML, element names are case-insensitive so ‘h1’ works just as well as ‘H1’ but not within real x(ht)ml (application/xhtml+xml) it should completely ignore any ‘H1’ styles as they don’t exist. You probably won’t get the effect with xhtml as backwards compatible ‘text/html’.
Okay, but I’m not contesting consistency…
I was just asking, “Is it okay to name a selector using Pascal Case or Camel Case?”
As far as I know, CSS is NOT case-sensitive, so it should not matter?!
TomTees
I see selectors as being similar to, but obviously not the same as, variables in a programming language.
Variables names in say javascript and php are case sensitive - eg. $str and $Str are 2 different variables with 2 diffrent memory locations in the server’s RAM.
So it goes back to my view on consistancy in using naming conventions throughout all your code for an application.
But this is just the way I do things. I’m not saying everyone else should do the same.
Why???
You will get people arguing very strongly on what naming conventions we should use.
From my point of view, you can choose whatever naming convention you like but you must be consistent with that convention throughout your code. This is partucularly important imho if some time down the track someone else will need to look at and/or modify your code for some reason.
If your code is unlikely to ever be looked at by someone else then it doesn’t matter if you are consistent with your naming convention or not.
Well, I have a selector that I’d like to be multiple words, and it reads better with Camel or Pascal case.
#wrapperLessFooter
TomTees
Yes it is for classes and IDs: http://reference.sitepoint.com/css/casesensitivity
I used Camel Case and it still seems to work, so I guess I’m okay.
Thanks,
Tom Tees
I don’t know if css selectors are case sensitive to their counterparts in the html but it should only take you a minute or so to code up some test code to test it.
In my first reply I said that even if selectors are not case sensitive you can use whatever naming convention you like and gave scenarios where I think it is important to be consistent in using naming conventions and where it isn’t.
So you can use pascal or camel case or any other naming convention you choose and whether consistency is important or not is up to each individual.
If you mean you would like to have Camel Case in the css and Pascal Case in the html then even if it does work, imho that is bad coding practice and not something I would encourage.
You will get people arguing very strongly on what naming conventions we should use.
From my point of view, you can choose whatever naming convention you like but you must be consistent with that convention throughout your code. This is partucularly important imho if some time down the track someone else will need to look at and/or modify your code for some reason.
If your code is unlikely to ever be looked at by someone else then it doesn’t matter if you are consistent with your naming convention or not.