www.webdeveloper.com
Results 1 to 4 of 4

Thread: Use of hyphen / underscore in css class / id names

  1. #1
    Join Date
    May 2006
    Posts
    100

    Use of hyphen / underscore in css class / id names

    Hello,

    Is there any reason why I should not use hyphens or underscore in css class names (class="example_1-2") or id names (id="example_1-2")?

    Thank you,
    Chris

  2. #2
    Join Date
    May 2005
    Location
    Gold Coast (MS)
    Posts
    2,198
    None that I know of. I use the underscore/hyphen all the time. Just remember do not start an ID name with a number! It will not work in Mozilla/Firefox. Do not start a class name with a number! This is only supported in Internet Explorer. Haven't verified if these exceptions are still a problem in the latest browsers.

  3. #3
    Join Date
    Feb 2012
    Posts
    83
    I dont think so because i used lot of hyphen and underscore in my site css

  4. #4
    Join Date
    Nov 2002
    Location
    Flint, Michigan, USA
    Posts
    586
    According to http://www.webdesignerdepot.com/2009...ove-your-code/, "Older browsers like to get glitchy with underscores in CSS, or don’t support them at all. For better backward compatibility, get into the habit of using hyphens instead."

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