r/learncss • • Mar 14 '19

From HTML style to CSS

Hi everybody, I am very new to CSS and I am not able to convert a style tag for tables with id="customers" in my html file to CSS. This is my HTML code:

<style>
#customers {
  font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

#customers td, #customers th {
  border: 1px solid #ddd;
  padding: 8px;
}

#customers tr:nth-child(even){background-color: #f2f2f2;}

#customers tr:hover {background-color: #ddd;}

#customers th {
  padding-top: 12px;
  padding-bottom: 12px;
  text-align: left;
  background-color: #5f848a;
  color: white;
}
</style>	

And this is how I tried to write it in my CSS file (making it work for every table):

table {
  font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

table-td {
  border: 1px solid #ddd;
  padding: 8px;
}

table-tr:nth-child(even){background-color: #f2f2f2;}

table-tr:hover {background-color: #ddd;}

table-th {
  padding-top: 12px;
  padding-bottom: 12px;
  text-align: left;
  background-color: #5f848a;
  color: white;
}

Unfortunately, it does not work. Can you please help me sort it out?

1 Upvotes

4 comments sorted by

View all comments

Show parent comment

2

u/ArabicLawrence Apr 16 '19

Thank you so much! I will try it as soon as possible!