76

What's the HTML character entity for the # sign? I've looked around for "pound" (which keeps returning the currency), and "hash" and "number", but what I try doesn't seem to turn into the right character.

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
chimerical
  • 5,883
  • 8
  • 31
  • 37
  • 12
    You should have searched for "octothorpe" – A. Levy Jun 11 '10 at 18:18
  • 7
    Just out of curiosity, why do you need it? # isn't a reserved character in HTML... If you need to escape it in a URL (to avoid starting a fragment), then using the HTML escape won't do you much good. – Shog9 Jun 11 '10 at 18:19
  • ...have you tried not using a character entity? If you view the source for this page no entity is being used to make the # characters. – badp Jun 11 '10 at 18:22
  • i believe stack overflow uses utf-8. what i've inherited doesn't, so that's why. – chimerical Jun 11 '10 at 19:03
  • 6
    @Shog9, Markdown interprets `#` as "headers", so we need to do `#` , See the source code of http://stackoverflow.com/q/8333376/632951 – Pacerier Feb 24 '15 at 03:24

9 Answers9

72

You can search it on the individual character at fileformat.info. Enter # as search string and the 1st hit will lead you to U+0023. Scroll a bit down to the 2nd table, Encodings, you'll see under each the following entries:

HTML Entity (decimal)  #
HTML Entity (hex)      #
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • A simple [ascii chart](https://www.google.com.sg/search?q=ascii+chart&espv=2&biw=1366&bih=677&source=lnms&tbm=isch&sa=X&ei=le3rVOmIDcfguQS7uIG4AQ&ved=0CAYQ_AUoAQ#imgdii=_&imgrc=2U31hF4tTw886M%253A%3Bs1dBG-qo3cDEJM%3Bhttp%253A%252F%252Fwww.asciitable.com%252Findex%252Fasciifull.gif%3Bhttp%253A%252F%252Fpdf.masdillah.com%252Fascii%252Fascii-symbols.html%3B715%3B488) will work just fine. – Pacerier Feb 24 '15 at 03:20
  • As indicated in another answer, there has been an update allowing to use `#` also. – holroy Mar 30 '19 at 20:05
  • thx for your answer. would you be able to elaborate a little more: what is the difference between using ` #` vs `#`? – BenKoshy Feb 11 '21 at 22:48
  • @BKSpurgeon: one is written in decimal notation other is written in hex notation. – BalusC Feb 12 '21 at 08:35
  • What's the meaning of # in the URL https://en.wikipedia.org/wiki/Star_formation#Protostar? – user610620 Sep 08 '22 at 01:59
  • @user610620: https://en.wikipedia.org/wiki/URI_fragment – BalusC Sep 08 '22 at 08:20
  • Thanks @BalusC. Now, how is it that # URI fragments for moving down to a lower section of a page is also used for # URI fragments that let people toggle through different columns of a table? Are both usages dependent on HTML or Javacript code? and how do their code differ – user610620 Sep 08 '22 at 23:08
  • @user610620: https://developer.mozilla.org/en-US/docs/Web/API/Window/hashchange_event – BalusC Sep 09 '22 at 08:42
25

For # we have #.

Bear in mind, though, it is a new entity (IE9 can't recognize it, for instance). For wide support, you'll have to resort, as said by others, the numerical references # and, in hex, &#x23.

If you need to find out others, there are some very useful tools around.

acdcjunior
  • 132,397
  • 37
  • 331
  • 304
17

The "#" -- like most Unicode characters -- has no particular name assigned to it in the W3 list of "Character entity references" http://www.w3.org/TR/html4/sgml/entities.html . So in HTML it is either represented by itself as "#" or a numeric character entity "#" or "#" (without quotes), as described in "HTML Document Representation" http://www.w3.org/TR/html4/charset.html .

Alas, all three of these are useless for escaping it in a URL. To transmit a "#" character to the web server in a URL, you want to use "URL encoding" aka "percent encoding" as described in RFC 3986, and replace each "#" with a "%23" (without quotes).

David Cary
  • 5,250
  • 6
  • 53
  • 66
  • 2
    percent encoding is especially important when (sigh) your query sting includes an octothorpe, e.g.: `http://example.com?search=term#37` where `term#37` is your query string. – adam rowe May 02 '17 at 13:53
9

There is no HTML character entity for the # character, as the character has no special meaning in HTML.

You have to use a character code entity like # if you wish to HTML encode it for some reason.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005
8
# or #

http://www.asciitable.com/ has information. Wikipedia also has pages for most unicode characters.

http://en.wikipedia.org/wiki/Number_sign

whatsisname
  • 5,872
  • 2
  • 20
  • 27
4

The numerical reference is #.

Matthew Flaschen
  • 278,309
  • 50
  • 514
  • 539
4

You can display "#" in some ways as shown below:

# or # or #

In addtion, you can display "♯" which is different from "#" in some ways as shown below:

♯ or ♯ or ♯
sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
2

We've got some wild answers here and actually we might have to cut hairs to determine if it qualifies as an HTML Entity, but what I believe you're looking for is the named anchor.

This allows references to different sections within an HTML document via hyperlink and specifically uses the octothorp (hash symbol, number symbol, pound symbol)

exampleDomain.com/exampleSilo/examplePage.html#2ndBase

Would be an example of how it's used.

systemaddict
  • 363
  • 2
  • 13
-1

# is the best option because it is the only one that doesn't include the # (hash) in it. Supported by old browsers or not, it is the best practice going forward.

(What is the point of encoding something using the same symbol you are encoding?)

  • 1
    Various reason could exist. One which I've experienced is to avoid markdown triggering a number list when the hashtag is used as the first character on a line. – holroy Mar 30 '19 at 20:04