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
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= " ";
</script>
You could simply use the HTML for the ampersand as in &nbsp;
which would display what you're looking for, i.e.
You will need to write out a part of the code, in this example, I'll use the ampersand. Instead of writing
, write out the ampersand, &
, and then write nbsp;. Your final result should be &nbsp;
, which will display
on the webpage.
You can use &
instead of &
So
will be &nbsp;