CSS- when do use periods when setting a class

Hi there,

I noticed when I was working on the CSS unit that when you are making some classes (for example body) you do not use a period before:
Ex>
body{ background-color: brown;}

However when you use other titles for classes, you have to add the period:
ex:
.pink-text{color: pink;}

How do you know if you will need to add the period or not before the class?

Thanks :smiley:

If you refer to a tag, you write the name - “body” is a tag, as in <body> ... </body>
If you refer to a class, you write the period - “.pink-text” is a class, as in <p class="pink-text">...</p>
If you refer to an ID (comes later), you write a hastag - “#top-header” is an id, as in <div id="top-header">...</div>

This is great thank you! I don’t think I really solidified the difference between tag, class and ID yet so this is really helpful.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.