This forum is now read-only. Please use our new forums at discuss.codecademy.com.

CSS: An Overview Forum

View Course » View Exercise

1087 points
48b7ef934aecc2ed336af2cc22d203ba?s=140&d=retro
Submitted by
zweig
almost 2 years ago

Why can't I use semi-colon after final curly braces?

h1 {
font-family: Verdana;
}

h3 {
    font-family: Courier; /* This isn't working, though.*/
}

p {
    color: purple;
};

This works.

This doesn't:

h1 {
    font-family: Verdana;
};

h3 {
    font-family: Courier; /* This isn't working, though.*/
};

p {
    color: purple;
};

Why?


0 votes

permalink

Have you been learning php well?

Anyway, we can't because that is not how css works, css has the following general syntax:

selector {
property: value;
property: value;
property: value;
}

the semi-colons are used to separate property's and there corresponding values. the curly brackets are used to tell which rules belong to which selector. You don't use semi-colons for that.

2455 points
593d545c83696644420003b7_64554016
Submitted by
stetim94
almost 2 years ago

2 Comments

48b7ef934aecc2ed336af2cc22d203ba?s=140&d=retro zweig almost 2 years ago

I've been learning JavaScript and it emphasized usage of semi-colons, but now I know that CSS doesn't require it to the same extent. Thanks.

593d545c83696644420003b7_64554016 stetim94 almost 2 years ago

javascript also needs a lot of semi-colons. But they are different, so you have to remember that. Programming language are like normal language. If you talk to someone in english and then start to mix it with spanish. Same with programming languages, each language needs its own syntax