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

4

12

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?

Almuce answered 2/7, 2013 at 14:4 Comment(3)
you already did it here!Woald
yes but it was done using stackoverflow's text editor. Apparently it doesn't recognize  Almuce
@user2118228 He was able to do it here because on the SO website, putting any text between two backquotes causes it to display as is. For example...  Iridaceous
S
26

You can use & instead of & So   will be  

Shekinah answered 2/7, 2013 at 14:9 Comment(3)
Everybody said the same thing, but Accepted for simplicity.Almuce
The answer is incorrect, because the pre tag does not affect the interpretation of entity references.Musketry
Sorry. Really option with pre-tag is nonsense. So answer updatedShekinah
I
4

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  , which will display   on the webpage.

Iridaceous answered 2/7, 2013 at 14:8 Comment(0)
S
1

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

Slaphappy answered 2/7, 2013 at 14:15 Comment(0)
B
0

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>
Boutonniere answered 3/6, 2020 at 7:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.