HTML_Extract: How to do css selector to get Row1 & Highlighted Row X

I’ve below HTML sample

<!DOCTYPE html>
table, th, td {
  border:1px solid black;

<h2>A basic HTML table</h2>

<table style="width:100%">
    <td><span style="background:#ffd700">Medium</span></td>
    <td><span style="color:#808080">Low</span></td>
    <td><span style="color:#808080">Medium</span></td>
    <td><span style="color:#ff0000">High</span></td>
    <td><span style="color:#0000ff">Management</span></td>


The Leftmost Column is the “Key” and any highlighted/differently-coloured is the “Value”.
Any chance on how to pair them key & value?

For example the final output needed is

  • Priority=Medium
  • Risk=High
  • Hostname=aws-12345
  • Team=Management

Thanks in advance

Hey @getk, CSS selectors aren’t a concept specific to n8n, so you might want to take a look for example at W3Schools for more information on this:

A very simple approach of getting the right selector for a given value would be to open the HTML page in a browser, right click the value you’re interested in and select Inspect. Most browsers will then allow you to copy the CSS selector from the source code by right clicking it, like Firefox for example:


So a valid selector for “Medium” would be body > table:nth-child(2) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > span:nth-child(1)

You can then use this selector in the HTML Extract node like so:

Hope this helps!

1 Like

thank you as Always. Very helpful

1 Like