Search code examples
javascripthtmlformatting

Inserting smiley into the HTML


How do I insert a smiley in the HTML programatically? I want to know the logic as how does it exist along with text? Is it a styled ASCII character or something? thanks in advance.


Solution

  • Assuming you mean smilies as found in various forums, you simply replace the ASCII smiley with a HTML img element on the server side. The output will look like this:

    <p>This is a paragraph <img src="wink.png" alt=";)"></p>
    

    Most of the time this is achieved using e.g. the PHP str_replace function.