How to write out HTML entity name ( , <, >, etc)

后端 未结 4 497
生来不讨喜
生来不讨喜 2020-12-03 22:29

How would I write the entity name in HTML and not have it do its function? Example: I\'m doing a tutorial and want to tell someone how to use the non-breaking space in their

相关标签:
4条回答
  • 2020-12-03 22:47

    JavaScript can be used to change the text of HTML element, below example adds non-blocking space entity character into span element.

    <p>A common character entity used in HTML is the non-breaking space: <span id="myid"></span></p>
      <script>
        document.getElementById("myid").textContent= "&nbsp;";
      </script>
    
    0 讨论(0)
  • 2020-12-03 23:04

    You could simply use the HTML for the ampersand as in &amp;nbsp; which would display what you're looking for, i.e. &nbsp;

    0 讨论(0)
  • 2020-12-03 23:06

    You will need to write out a part of the code, in this example, I'll use the ampersand. Instead of writing &nbsp;, write out the ampersand, &amp;, and then write nbsp;. Your final result should be &amp;nbsp;, which will display &nbsp; on the webpage.

    0 讨论(0)
  • 2020-12-03 23:09

    You can use &amp; instead of & So &nbsp; will be &amp;nbsp;

    0 讨论(0)
提交回复
热议问题