'Display "#" symbol in html?
This is driving me nuts - I want to just display a hash symbol (#) in html but it just won't show it.
I've tried # but nothing shows.
I want to put it at the start of my title tag like so:
<img src="<?php echo $fields->image; ?>" alt="<?php echo $fields->dish_name; ?>" height="160" width="314" title="# <?php echo $fields->dish_number; ?> <?php echo $fields->dish_name; ?>" />
Update: http://www.orientalcatering.co.uk/v1/ This is the page I'm working on, it's the second slider towards the bottom right of the page that I'm trying to get a comment up in (you use the title tag to do this).
Solution 1:[1]
There is nothing special about the “#” character as data in HTML, any more than about the letter “A.” (And if there were, “#” would not help much, would it, as it contains the “#” character.)
The problem is rather with the mechanism used to change images. This seems to be somewhat complicated, but it results in hiding an img element and using a background image instead. When the img element is hidden using display: none, its attributes have no effect.
Thus, you need a different mechanism for changing the image (I wonder why a simple JavaScript-driven image changer, directly modifyin the attributes of an img element, hasn’t been used), or maybe a tooltip-like mechanism implemented in JavaScript and CSS rather than with simple title attribute.
Solution 2:[2]
I believe it should be # for a hex symbol.
Solution 3:[3]
There has to be an error either with php somewhere, or there's some sort of character sanitation happening elsewhere.
I say that because having a # in a title is not a problem: http://jsfiddle.net/T5GyL/
Try just doing a non-php snippet first to see if it really is a problem
Solution 4:[4]
Educated guess: You have a ISO-8859-1 encoded pound sign in a UTF-8 encoded page.
Make sure your data is in the right encoding and everything will work fine.
Solution 5:[5]
These are how you display "#" in some ways as shown below:
# or # or #
In addtion, these are how you display "?" which is different from "#" in some ways as shown below:
♯ or ♯ or ♯
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jukka K. Korpela |
| Solution 2 | Wei Hao |
| Solution 3 | Kristian |
| Solution 4 | Community |
| Solution 5 | Kai - Kazuya Ito |
