1

In an UTF-8 encoded HTML document, is it valid to use an IDN as a value for src and href attributes?

<a href="http://موقع.وزارة-الاتصالات.مصر/">ICT</a>

Are there any objections that enforce the use of the Punycode-encoded version?

<a href="http://xn--4gbrim.xn----ymcbaaajlc6dj7bxne2c.xn--wgbh1c/">ICT</a>

I’m not sure if modern user agents treat a href as an “IDN-unaware domain name slot”.

dakab
  • 5,379
  • 9
  • 43
  • 67

1 Answers1

1

Looking at the HTML specification for a-tag is says that href is a hyperlink.

When I answered this in 2014, it said that href was an URI and that URI was defined in RFC3987 Internationalized Resource Identifiers. If you follow the links from hyperlink, you find a link to the URL: Living standard that mentions both RFC 3986 and RFC 3987 in the Goal.

From RFC 3987:

Abstract

This document defines a new protocol element, the Internationalized Resource Identifier (IRI), as a complement to the Uniform Resource Identifier (URI). An IRI is a sequence of characters from the Universal Character Set (Unicode/ISO 10646). A mapping from IRIs to URIs is defined, which means that IRIs can be used instead of URIs, where appropriate, to identify resources.

So the simple answer is: yes, you can use idn in href, at least for HTML 5 documents. You should however look at RFC 3987 section 4 if your text is bidirectional.

This answer was updated in 2018, after JohnT asked me to update the broken links.

Community
  • 1
  • 1
some
  • 48,070
  • 14
  • 77
  • 93
  • Could you please update the first two links? They are broken. – JohnT Nov 08 '18 at 17:55
  • What I see in the 5.2 standard is "The href attribute on a and area elements must have a value that is a valid URL potentially surrounded by spaces." Following the chain of links starting with "valid URL potentially surrounded by spaces" one ends up at a vague statement that " one may wish to consider [RFC3986] [RFC3987]". But one of these defines URI (no non-ASCII) while the other defines IRI, Which is valid is therefore still unclear. – JohnT Nov 08 '18 at 17:59