Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6580373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:01:17+00:00 2026-05-25T16:01:17+00:00

Is the ampersand the only character that should be encoded in an HTML attribute?

  • 0

Is the ampersand the only character that should be encoded in an HTML attribute?

It’s well known that this won’t pass validation:

<a href="http://domain.com/search?q=whatever&lang=en"></a>

Because the ampersand should be &amp;. Here’s a direct link to the validation fail.

This guy lists a bunch of characters that should be encoded, but he’s wrong. If you encode the first “/” in http:// the href won’t work.

In ASP.NET, is there a helper method already built to handle this? Stuff like Server.UrlEncode and HtmlEncode obviously don’t work – those are for different purposes.

I can build my own simple extension method (like .ToAttributeView()) which does a simple string replace.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:01:17+00:00Added an answer on May 25, 2026 at 4:01 pm

    Other than standard URI encoding of the values, & is the only character related to HTML entities that you have to worry about simply because this is the character that begins every HTML entity. Take for example the following URL:

    http://query.com/?q=foo&lt=bar&gt=baz
    

    Even though there aren’t trailing semi-colons, since &lt; is the entity for < and &gt; is the entity for >, some old browsers would translate this URL to:

    http://query.com/?q=foo<=bar>=baz
    

    So you need to specify & as &amp; to prevent this from occurring for links within an HTML parsed document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find the keycode for ampersand and underscore. I should not
Say I have a string that looks like this: str = The &yquick &cbrown
How can I convert special characters to HTML in JavaScript? Example: & (ampersand) becomes
What does the ampersand mean in this code? int clothes = (random.nextInt(0x1000000) & 0x7f7f7f);
I want to pass the ampersand '&' sign in text via ajax to php
I have a query string parameter value that contains an ampersand. For example, a
When we insert a string with ampersand character into mysql, the string is inserted
I get an expat error when parsing specific characters only. Other HTML code is
To indicate an argument is passed by reference to the function, what character should
have problem with ampersand (&) How to search for the words (or sentences) that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.