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}>

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
  // Append the text
  // Append that inner span to the anchor
  // Now have a full link ready to put into the document:
  return link;

// When you want to create & add the link:
const myLink = createLink("", "I'm a link", "exampleClass1", "exampleClass2");