Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is URL encoding "href" attribute of a anchor element necessary?

I checked the HTML code of my webpage and validated it using Firefox's HTML Validator add-on, and I saw that it complaints about the href attribute of a link, which contains Unicode characters, which are not URL encoded.

The current URL is:

<a href='/اخبار'>Persian News</a>

However, the validator wants it to be:

<a href='/%D8%A7%D8%AE%D8%A8%D8%A7%D8%B1'>Persian News</>

I've tested this link in almost every browser (even back to IE6). It works just fine. So, what is the problem here? Why should I encode it? Is validator out of date? What problem may I encounter of not URL encoding Unicode characters inside the href attribute of an <a>tag?

like image 461
Saeed Neamati Avatar asked Jan 18 '23 09:01

Saeed Neamati


1 Answers

URLs can only be sent over the Internet using the ASCII character-set.

Usually, browser does the encoding for you.

like image 87
hoymkot Avatar answered Jan 30 '23 02:01

hoymkot