www.webdeveloper.com
Results 1 to 7 of 7

Thread: Caps or not?

  1. #1
    Join Date
    Jan 2005
    Location
    USA
    Posts
    19

    Caps or not?

    Hi guys,

    I read yesterday, that there in CSS, all classes and ids should be defined using small characters. is this true?

    does it mean that with i have a class myBoat it might not work in some browsers?


    And another questions, is it better to name images like myBoat.jpg or myboat.jpg?

    Thanks.

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Quote Originally Posted by tigerasya
    I read yesterday, that there in CSS, all classes and ids should be defined using small characters. is this true?
    Where did you read that, HTML Goodies? Just match the case used in the HTML but assume case insensitivity - don't assume that "myBoeat" and "myboat" are two different classes.

    I prefer "my-boat".
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    Jan 2005
    Location
    USA
    Posts
    19
    That's the thing..i don't remember where i read it...i might have been even at ths forum....but i'm not sure...

  4. #4
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    Consistency is the key. If you use lowercase for all of your HTML and CSS (tag, class and id names) then you don't need to worry about whether a given browser will be case sensitive or not. You do need to use the correct capitalisation for the attributes assigned within the CSS.

    XHTML is case sensitive, HTML is not.
    Stephen

  5. #5
    Join Date
    Jan 2005
    Location
    USA
    Posts
    19
    Thanks for your response, felgall. This information was more than helpful.

    Thanks again.

  6. #6
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    However, a given browser might take XHTML to be HTML in which case myBoat will incorrectly be taken to be the same as myboat.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  7. #7
    Join Date
    Dec 2005
    Location
    American, living in Toronto, ON. CANADA
    Posts
    6,746
    W3C says "....it is recommended that the mixed capitalization be used to make the names more legible", however, if you mix the case incorrectly (inconsistantly), the rule will be ignored.
    Therefore, #thisSection {} in the CSS won't be used if referanced in the HTML as <div id="ThisSection">~</div>
    Personally, -I prefer using all lower-case letters, always. And if you use a semantic naming convention for your elements (e.g., #left_column, #right_column, #mainbodytext, #banner, #footer, etc.), it will 'make sence' later when you or someone else is reading or editing it because it was named intuitively.
    Naming conventions like #this, #that, #nothisone, #andnowthis, are non-semantic and even though they match their HTML counterpart and would be correct, -they don't make intuitive sence at first glance and create the possibility of errors.

    Lower case all the time works.
    Last edited by WebJoel; 06-22-2006 at 09:02 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles