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
over 1 year 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.

2410 points
5671826195e378c47d000782_659060817
Submitted by
stetim94
over 1 year ago

2 Comments

48b7ef934aecc2ed336af2cc22d203ba?s=140&d=retro zweig over 1 year 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.

5671826195e378c47d000782_659060817 stetim94 over 1 year 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