CSS: Beginner question

body {
    background-color: #d0e4fe;

h1 {
    color: orange;
    text-align: center;

p {
    font-family: "Times New Roman";
    font-size: 20px;

Open in new window

I was trying to learn CSS at w3schools.com. I am seeing that normal style tags look like the above. I then came across a CSS file in one of my company's projects that looks like this:

.tableBorder td, .grid td
   vertical-align: top;
   padding: 2px;
   border: 1px solid #ccc

1) Why does it begin with a dot? (.tableBorder). Why not just tableBorder?
2) When it comes to naming the style, doe sit matter if you type .tableBorder vs. tableBorder (without the dot) -- Is there a syntax you're suppose to follow or is it loose?
3) What is the td after .tableBorder? I know it stands for "table data", but why is it there. Is that short-hand so you don't have to create a duplicate style block for td as well?
4) Why is there a comma after the td, followed by .grid?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
The dot '.' means that tableBorder and grid are classes which can be applied to many elements.  .tableBorder td means that it only applies to <td> elements in those classes.  The comma means that it is a list of items that those descriptions are used for.

A '#' instead of a dot '.' makes it an 'id' and 'id's are supposed to be unique on a page so that javascript can find the correct element.  Any HTML element like <td> and <p> can be listed in the CSS without a '.' or '#' in front of it.  The CSS will then apply to all <td>s or <p>s.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.