Search code examples
htmlhyperlinkbookmarks

HTML bookmark links not working


I'm working on an HTML page with bookmark links (a href/a id) and when I validated the page on W3C the validator told me that whitespace wasn't allowed in links and that I should replace it with %20 and so I did with a PHP function. After doing that my bookmark links stopped working. Then, instead of replacing the whitespace with %20 I tried replacing it with an empty string ("") and thus removed the whitespace altogether and my bookmarks started working again. Can anybody explain this?


Solution

  • Some PHP code might be helpful but I think it's enough if you use urlencode() function. It will auto-magically convert any string to match the URL standards.

    Here's the REFERENCE.