Reputation: 2067
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 code (
) So, how to actually write out "&" "n" "b" "s" "p" ";" but have it be fluid with no spaces?
Upvotes: 12
Views: 20409
Reputation: 61
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>
Upvotes: 0
Reputation: 652
You can use &
instead of &
So
will be &nbsp;
Upvotes: 26
Reputation: 360
You could simply use the HTML for the ampersand as in &nbsp;
which would display what you're looking for, i.e.
Upvotes: 1
Reputation:
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.
Upvotes: 4