score:1

Accepted answer

You are missing a <tr> on your header row:

var thead = d3.select("thead")
  .append("tr") //<-- missing tr
  .selectAll("th")
  .data(d3.keys(stations[0]))
  .enter().append("th").text(function(d) {
    return d
  });

Update fiddle.

In your working version, the browser is correcting the malformed HTML when it parses it:

<thead>
  <tr><th>name</th> <!-- what the browser actually renders -->
  <th>city</th>
</tr></thead>

Related Query

More Query from same tag