Grow your CSS skills. Land your dream job.

scss variable naming

  • # July 15, 2013 at 6:04 am

    Hi,

    i am in the process of creatinga responsive grid with scss and I was naming my variables like so

    $1col: 6.25%;
    $2col: 12.5%;
    etc etc

    I was getting scss compilation errors saying ‘

    > > Syntax error: Invalid CSS after “$”: expected identifier, was “1col: 6.25%” on line 75 of C:………….

    So guessing the identifier they were talking about was a css identifier I renamed the variables to

    $width1col: 6.25%;
    $width2col: 12.5%;
    etc etc

    and the compilation succeeded, does there really have to be a css identifier name in ever variable I create in scss? why does the name matter? I have seen variable names called simply $blue that work, why do these work and not other descriptive names that dont include identifiers?

    I feel like I am missing something obvious, what is it?

    # July 15, 2013 at 6:35 am

    Classes and IDs cannot start with numbers so I would guess that the same is true of variables.

    # July 15, 2013 at 7:09 am

    You are dead right thanks

    # July 16, 2013 at 1:52 am

    Not that I suggest starting an HTML class name with a number, but it is valid HTML. This isn’t true for IDs, however.

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

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".