Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1>Aligning table cells based on header</h1>
<h2>Last two columns have aligned text</h2>
<p>Proof of concept works for up to 5 columns, can be extened to more..</p>
<p>Number of rows doesn't matter.</p>
<hr>
<table border="1">
<caption>u.s. women's national team (2018)</caption>
<colgroup>
	<col class="name">
	<col class="number center">
	<col class="position center">
	<col class="games right">
	<col class="goals right">
	<col class="assists right">
</colgroup>
<thead>
	<tr>
		<th>name</th>
		<th>#</th>
		<th>position</th>
		<th>games</th>
		<th>goals</th>
		<th>assists</th>
	</tr>
</thead>
<tbody>
	<tr>
		<td>morgan brian</td>
		<td>6</td>
		<td>midfielder</td>
		<td>83</td>
		<td>6</td>
		<td>11</td>
	</tr>
	<tr>
		<td>abby dahlkemper</td>
		<td>7</td>
		<td>defender</td>
		<td>47</td>
		<td>0</td>
		<td>3</td>
	</tr>
	<tr>
		<td>tierna davidson</td>
		<td>12</td>
		<td>defender</td>
		<td>21</td>
		<td>1</td>
		<td>5</td>
	</tr>
	<tr>
		<td>crystal dunn</td>
		<td>19</td>
		<td>defender</td>
		<td>91</td>
		<td>24</td>
		<td>16</td>
	</tr>
	<tr>
		<td>julie ertz</td>
		<td>8</td>
		<td>midfielder</td>
		<td>88</td>
		<td>19</td>
		<td>2</td>
	</tr>
	<tr>
		<td>adrianna franch</td>
		<td>21</td>
		<td>goalkeeper</td>
		<td>1</td>
		<td>0 cs</td>
		<td></td>
	</tr>
	<tr>
		<td>ashlyn harris</td>
		<td>18</td>
		<td>goalkeeper</td>
		<td>14</td>
		<td>5 cs</td>
		<td></td>
	</tr>
	<tr>
		<td>tobin heath</td>
		<td>17</td>
		<td>forward</td>
		<td>156</td>
		<td>30</td>
		<td>38</td>
	</tr>
	<tr>
		<td>lindsey horan</td>
		<td>9</td>
		<td>midfielder</td>
		<td>74</td>
		<td>10</td>
		<td>23</td>
	</tr>
	<tr>
		<td>ali krieger</td>
		<td>11</td>
		<td>defender</td>
		<td>103</td>
		<td>1</td>
		<td>8</td>
	</tr>
	<tr>
		<td>rose lavelle</td>
		<td>16</td>
		<td>midfielder</td>
		<td>33</td>
		<td>10</td>
		<td>5</td>
	</tr>
	<tr>
		<td>carli lloyd</td>
		<td>10</td>
		<td>forward</td>
		<td>281</td>
		<td>113</td>
		<td>52</td>
	</tr>
	<tr>
		<td>allie long</td>
		<td>20</td>
		<td>midfielder</td>
		<td>45</td>
		<td>6</td>
		<td>3</td>
	</tr>
	<tr>
		<td>jessica mcdonald</td>
		<td>22</td>
		<td>forward</td>
		<td>8</td>
		<td>2</td>
		<td>0</td>
	</tr>
	<tr>
		<td>samantha mewis</td>
		<td>3</td>
		<td>midfielder</td>
		<td>56</td>
		<td>14</td>
		<td>5</td>
	</tr>
	<tr>
		<td>alex morgan</td>
		<td>13</td>
		<td>forward</td>
		<td>169</td>
		<td>107</td>
		<td>43</td>
	</tr>
	<tr>
		<td>alyssa naeher</td>
		<td>1</td>
		<td>goalkeeper</td>
		<td>53</td>
		<td>28 cs</td>
				<td></td>
	</tr>
	<tr>
		<td>kelley o'hara</td>
		<td>5</td>
		<td>defender</td>
		<td>124</td>
		<td>2</td>
		<td>17</td>
	</tr>
	<tr>
		<td>christen press</td>
		<td>23</td>
		<td>forward</td>
		<td>123</td>
		<td>49</td>
		<td>30</td>
	</tr>
	<tr>
		<td>mallory pugh</td>
		<td>2</td>
		<td>forward</td>
		<td>56</td>
		<td>16</td>
		<td>16</td>
	</tr>
	<tr>
		<td>megan rapinoe</td>
		<td>15</td>
		<td>forward</td>
		<td>158</td>
		<td>50</td>
		<td>59</td>
	</tr>
	<tr>
		<td>becky sauerbrunn</td>
		<td>4</td>
		<td>defender</td>
		<td>164</td>
		<td>0</td>
		<td>7</td>
	</tr>
	<tr>
		<td>emily sonnett</td>
		<td>14</td>
		<td>defender</td>
		<td>32</td>
		<td>0</td>
		<td>3</td>
	</tr>
</tbody>
<tfoot>
	<tr>
		<th>name</th>
		<th>#</th>
		<th>position</th>
		<th>games</th>
		<th>goals</th>
		<th>assists</th>
	</tr>
</tfoot>
</table>
              
            
!

CSS

              
                table:has(col.right:last-child) tbody tr > :last-child,
table:has(col.right:nth-last-of-type(2)) tbody tr > :nth-last-of-type(2),
table:has(col.right:nth-last-of-type(3)) tbody tr >  :nth-last-of-type(3) ,
table:has(col.right:nth-last-of-type(4)) tbody tr > :nth-last-of-type(4) ,
table:has(col.right:nth-last-of-type(5)) tbody tr > :nth-last-of-type(5)  {
	text-align: right;
}
table:has(col.center:nth-last-of-type(1)) tbody tr > :nth-last-of-type(1) ,
table:has(col.center:nth-last-of-type(2)) tbody tr > :nth-last-of-type(2) ,
table:has(col.center:nth-last-of-type(3)) tbody tr > :nth-last-of-type(3) ,
table:has(col.center:nth-last-of-type(4)) tbody tr > :nth-last-of-type(4) ,
table:has(col.center:nth-last-of-type(5)) tbody tr > :nth-last-of-type(5) {
	text-align: center;
}

td {min-width: 5em;}

              
            
!

JS

              
                
              
            
!
999px

Console