Add html tag inline to javascript

I try to add a html tag such as div or span to my javascript code.
Reason is to give the part of " ("+tag.length+")"… some css styling.

How to do?

Following is full code line .js:

'<a href="' + self.url_for(tag.path)  +" ("+tag.length+")"+`

You seem to be missing some code in what you posted. This can work:

const myLink = `
<a href="${theUrl}">
  <span class="${theClass}>
    ${theText}
  </span>
</a>
`;

Or this, more verbose but more robust:

function createLink(href, text, ...classes) {
  // Create the anchor:
  const link = document.createElement('a');
  // Add the href:
  link.href = href;
  // Create the inner element + the text to go inside:
  const inner = document.createElement('span');
  const innerText = document.createTextNode(text);
  // Add any classes
  inner.classList.add(...classes);
  // Append the text
  inner.appendChild(innerText);
  // Append that inner span to the anchor
  link.appendChild(inner)
  // Now have a full link ready to put into the document:
  return link;
}

// When you want to create & add the link:
const myLink = createLink("www.example.com", "I'm a link", "exampleClass1", "exampleClass2");
document.body.appendChild(myLink);