The browser wraps your new rows in <tbody> elements when you concatenate a new row directly to the table element, so each subsequent row is a single row per new <tbody>, making it apply to the nth-child(odd) selector. This explains why constructing new HTML from scratch and assigning it to the table doesn't show that problem. You can see this by inspecting the HTML generated in your browser's developer console when you run this example: