Rafael
Rafael

Reputation: 25

Bad value in a href attribute: "Illegal character in query: >"

I'm getting this error at W3C validator:

Bad value https://www.ncbi.nlm.nih.gov/snp?term=c.1047A>T for attribute href on element a:

Illegal character in query: > is not allowed.

ar</a> or <a href="https://www.ncbi.nlm.nih.gov/snp?term=c.1047A&gt;T" target="_blank">dbSNP<

I tried change > to &gt;, but it didn't work, and I need pass this character at URL: >. I tried to use urlencode() function from PHP and htmlentities(), but it didn't solve this error.

A piece of code:

<a href="https://www.ncbi.nlm.nih.gov/clinvar/?term=c.-247C&gt;T" target="_blank">ClinVar</a> or <a href="https://www.ncbi.nlm.nih.gov/snp?term=c.-247C&gt;T" target="_blank">dbSNP</a>
<a href="https://www.ncbi.nlm.nih.gov/clinvar/?term=c.-316T&gt;C" target="_blank">ClinVar</a> or <a href="https://www.ncbi.nlm.nih.gov/snp?term=c.-316T&gt;C" target="_blank">dbSNP</a>

This code is to generate a direct URL into a external search using all data from the DB and need to use > character.

How I can fix this

Upvotes: 1

Views: 1598

Answers (1)

An0num0us
An0num0us

Reputation: 961

You have to url encode them, not HTML encode them. The correct code for > is %3E.

Upvotes: 4

Related Questions