Different <style> in different templates nodes in the same dashboard

Hi guys,

I'm a newbie of NodeRed and I'm trying to build some HTML table using Template nodes.

I create many different table in dashboard using a template node for each one.

Now I would like to alternate color in rows and I use the following piece of code:

tr:nth-child(even) {
** background-color: #efecca;**

All works well but I note that this behavior are applied to all table in the dashboard even if the other nodes do not contain the code.

How is it possible to apply the only in one node?


You need to target your css to the template more accurately. Typically you have a dive within your template to which you can assign an id=.... then get the css to target tr within that.

Thanks for reply!

Where is it possible to find an example?

Thanks again


Similar post. Just add a wrapper around your code with unique class/ID

/* instead of current */
.foo {...}
/* add wrapper */
.unique-wrapper-name .foo {...}
<div class="unique-wrapper-name">
  <div class="foo">your actual code here</div>

I don't understand how modify my code below for apply style only in current node.
I'm very newbie...


tr:nth-of-type(odd) {
    background: white;

tr:nth-of-type(even) {
    background: yellow;


<table style="width:100%">
  <tr ng-repeat="x in msg.payload | limitTo:100">

I would add classes to your table, like so:

<table class="odd-rows-white even-rows-yellow" style="width:100%">

Then your CSS rules can target rows in only the tables that have those class, like so:

  table.odd-rows-white tr:nth-of-type(odd) {
    background: white;
  table.even-rows-yellow tr:nth-of-type(even) {
    background: yellow;

If you include these "custom" styles in a single ui_template node, and check the box for "Added to Site <head> section" then it can apply to all of your dashboard templates -- so you don't have to repeat the styles in every ui_template node.

1 Like