# Tables skill test assessment

**URL:** <https://discourse.mozilla.org/t/tables-skill-test-assessment/113293>\
**Category:** Learn\
**Created:** [April 13, 2023, 9:52am UTC](https://discourse.mozilla.org/t/tables-skill-test-assessment/113293 "2023-04-13T09:52:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![user.dev](https://avatars.discourse-cdn.com/v4/letter/u/977dab/32.png) [@user.dev](https://discourse.mozilla.org/u/user.dev)\
**Post date:** [April 13, 2023, 9:52am UTC](https://discourse.mozilla.org/t/tables-skill-test-assessment/113293/1 "2023-04-13T09:52:01Z")

</div>

Page: [Test your skills: Tables](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Tables_tasks)

Task: [https://codepen.io/user\_un/pen/wvYMzNM](https://codepen.io/user_un/pen/wvYMzNM)

In the CSS file, selectors in line 17-20 are aligning headings and data for columns containing numbers right. Is there a shorter or better way to target (select) them? Writing 4 lines for that feels like writing bad code.

---

<div class="post-metadata">

**Author:** ![mikoMK](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/mikomk/32/50456_2.png) [@mikoMK](https://discourse.mozilla.org/u/mikoMK)\
**Post date:** [April 17, 2023, 4:39am UTC](https://discourse.mozilla.org/t/tables-skill-test-assessment/113293/2 "2023-04-17T04:39:30Z")

</div>

Hi @user.dev and welcome to the community 👋

You could reduce all the left/right alignment rules to the code below, but I think that about the most reduction you could get.

```auto
tr :nth-child(2),
tr :nth-child(3),
tfoot th {
  text-align: right;
}

tr,
tfoot :nth-child(2) {
  text-align: left;
}

```

There’s another possibility to style entire columns, but only a few properties are supported (border, background, width, visibility). Therefore this wouldn’t work with `text-align`, but maybe it’s helpful in another situation: [`<colgroup>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/colgroup) and classes on individual `<col>`s inside.

I hope that helps, 🙂  
Michael

PS: Your email address is visible in your post. It ended up in the optional “name” field of your profile. I recommend removing it.
