- white_imbalance += '<img src="' + svg_pieces['w' + piece.toUpperCase()] + '" alt="" style="width: 15px;height: 15px;" class="imbalance-piece">';
- white_imbalance += '<img src="' + svg_pieces['b' + piece.toUpperCase()] + '" alt="" style="width: 15px;height: 15px;" class="imbalance-inverted-piece">';
+ let i1 = document.createElement('img');
+ i1.src = svg_pieces['w' + piece.toUpperCase()];
+ i1.setAttribute('alt', piece.toUpperCase());
+ i1.classList.add('imbalance-piece');
+ white_imbalance.appendChild(i1);
+
+ let i2 = document.createElement('img');
+ i2.src = svg_pieces['b' + piece.toUpperCase()];
+ i2.setAttribute('alt', piece.toUpperCase());
+ i2.classList.add('imbalance-inverted-piece');
+ white_imbalance.appendChild(i2);