le_me
le_me

Reputation: 3419

Is it valid to escape html in a href attribute?

Assuming I have the following link:

<a href='http://google.com/bla'>http://google.com/bla</a>

Is this one also valid?

<a href='http:&#x2F;&#x2F;google.com/bla'>http://google.com/bla</a>

It works in Firefox, but I'm not sure if this is standardized behavior. I hope the question isn't super dumb!

Upvotes: 4

Views: 4950

Answers (1)

animuson
animuson

Reputation: 54729

Yes, it is perfectly valid to do that. In fact, the ampersand (&) character must be escaped into &amp; in order to be valid HTML, even inside the href attribute (and all attributes for that matter).

Upvotes: 7

Related Questions