Jump to content

does href attribute in a tags need to be encoded?


pauldenize

Recommended Posts

I had a web link like the following

 

<a href="someref?param1=123&param2=xyz">

 

It works fine but when validated - I get

 

general entity "param2" not defined and no default entity

 

note: in my example param2 is double_urlencoded = so looks more like param2=%252Fxyz)

 

Nothing I found says the whole parameter should be encoded

 

Link to comment
Share on other sites

What's wrong is the &. It thinks it's an HTML entity. Your document is probably using the XHTML doctype. In HTML it's valid to have loose ampersands.

Use an HTML entity to encode the & and you won't get any more warnings.

<a href="someref?param1=123&param2=xyz">

 

Yes, the URL will continue to work properly because the entity is parsed before the URL is used.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...