Gaurav Shah
Gaurav Shah

Reputation: 5279

Is it okay to use HTML entities in attributes?

I have been using slim, and suddenly noticed that it escapes everything by default. So the anchor tag looks something like this:

<a href="&#47;users&#47;lyann&#47;followers">
<img class="user-image" src="http:&#47;&#47;adasdasdasd.cloudfront.net&#47;users&# 47;2011&#47;05&#47;24&#47;4asdasd&#47;asdasd.jpg" />

Is it okay for the href and src attributes to be escaped like this? Are there any other implications? All browsers seems to render it without a problem, though.

Upvotes: 11

Views: 4346

Answers (1)

user1675187
user1675187

Reputation:

Yes, it's perfectly fine. Character references are valid inside attributes, too, and will be treated as character references just the same.

For reference, see:

Upvotes: 8

Related Questions