-1

I feel like this is HTML 101, and I'm missing something super obvious, but I couldn't figure out the search terms to find the answer to this. I have strong tags formatted a little differently in my code, and they always get their content pushed to a newline. If I have a strong tag that is inside some quotes, it automatically adds spaces around the strong text. If I include the quotes inside, I do not get this issue. If I remove the formatting, I do not get this issue.

I don't understand why the formatting would matter here, and why putting the quotes inside of the strong tag would fix the issue.

<span>
  Quotes outside strong will "<strong>
  have a space
  </strong>"
</span>
<br>
<span>
  Quotes inside strong will <strong>
  "not have a space"
  </strong>
</span>
<br>
<span>
  Quotes outside (but not formatting) will "<strong>not have a space</strong>"
</span>
<br>
<span>
  No quotes with strong will <strong>
  not have a space
  </strong>
</span>
incutonez
  • 3,241
  • 9
  • 43
  • 92
  • [This MDN article](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Whitespace) was very helpful. – incutonez Jun 09 '22 at 15:55

1 Answers1

3

that's due to the additional spaces in the HTML code which are created by your linebreaks inside the strong tag in the code. If you omit those, there will be no spaces between the quotes and the text inside the tag:

<span>
  Quotes outside strong will "<strong>NOT have a space</strong>"
</span>
  
Johannes
  • 64,305
  • 18
  • 73
  • 130