0

Does css have a way of applying a first and last child into one div? I want the first and last child to both have the same properties.

.productImageTable ul li:first-child{
    text-align: center;
    padding-top:40px;
    font-size: 20pt;
}

.productImageTable ul li:last-child{
    text-align: center;
    padding-top:40px;
    font-size: 20pt;
}
  • 2
    What do you mean by "into one div"? You can combine the selectors in one rule with a comma, if that's all you're after. – isherwood Feb 09 '21 at 22:10
  • Possible duplicate: https://stackoverflow.com/questions/57035939/how-to-combine-multiple-selectors-for-the-same-rule – isherwood Feb 09 '21 at 22:14

1 Answers1

1

You probably mean - apply the same rule for the first and last child at the same time. Just use comma:

.productImageTable ul li:first-child, .productImageTable ul li:last-child {
    text-align: center;
    padding-top:40px;
    font-size: 20pt;
}
Aitwar
  • 475
  • 2
  • 7