Treehouse: Grow your CSS skills. Land your dream job.

“#” sign before property

  • # May 29, 2012 at 12:14 pm

    Hello,

    I tried looking around the open web but couldn’t find anything, although there was an answer on Yahoo! Answers the ‘answer’ didn’t really say anything other than “[# is for IDs]” (no need to post the link of course).

    This is a bit more advanced.

    When reviewing the CSS code from a co-worker I found he used the # sign before several CSS properties.

    What does the # sign before property do? That’s gotta be some IE targeting hack I’m assuming.

    For example:

    .selector { #property:value; }

    or well:

    .headings { #margin-top:10px; }

    I thought I knew a lot about CSS but this one caught me by surprise, especially that there’s isn’t any documentation of this case out there on the open web other than that answer in Yahoo! Answers.

    Any info about this is greatly appreciated.

    Thanks.

    # May 29, 2012 at 12:27 pm

    The hashtag as it’s called means that it applies to an named element with an ‘id’




    You can then target this div directly with your CSS.



    #insertname {

    height: 250px;

    }

    for instance.

    # May 29, 2012 at 12:37 pm

    Hello Paulie,

    Thanks for your comment, but I think you didn’t read my question correctly. I wasn’t asking what is the # sign in CSS, I was asking about using the # sign within a CSS property.

    Anyway, I found the answer: Is a CSS hack for IE7 and below.

    Browser CSS hacks: http://paulirish.com/2009/browser-specific-css-hacks/
    The hash hack: http://www.kryogenix.org/code/browser/csshacks/hash

    Thanks!

    # May 29, 2012 at 1:20 pm

    If your co-worker really used that as a hack….it’s a terrible one in my opinion. Besides, using hacks in this day and age are really unnecessary.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.