New answers tagged

2

In (X)HTML5, the a element’s href attribute […] must have a value that is a valid URL potentially surrounded by spaces. As the anchor suggests, it may contain leading and trailing spaces. The linked section makes clear that these spaces will be stripped: […] the user agent must remove all space characters that are at the start or end of the string ...


0

Yes, it will be automagically corrected by the browser ,anyway if using spaces you get an error you can write them in another way: a URL, so a href, supports spaces, just replace them with "%20" Anyway if you write <a href="%20#id"> </a> This will result in a " #id" and not "#id" Eg: <a href="?How%20Are%20You">How are you?</a>


-1

You can run your markup through the validator yourself to find out if what you wrote is valid. But valid markup is not always an indication of valid transport and spaces must be URL encoded (and the hash mark also). You can learn more by searching Stackoverflow. In particular, this SO answer. Your characters are not safe to use.


0

Why would you do this? Who writes code like that? That's unnecessary space in between "". Literal spaces are not allowed in URLs and they are not part of the data. just formatting for human consumption. You need to remove the whitespace. Some browsers render it as a space. Spaces are valid. And they both are different because, one has spaces, other ...



Top 50 recent answers are included