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

  • Home
  • SEARCH
  • 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 8786065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:31:13+00:00 2026-06-13T21:31:13+00:00

I came across a post on Meta SO and I’m curious about what are

  • 0

I came across a post on Meta SO and I’m curious about what are the subtle differences between un-encoded and encoded HTML characters, in HTML attributes, in contexts of: security, best-practice and browser support.

  • 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-06-13T21:31:14+00:00Added an answer on June 13, 2026 at 9:31 pm

    HTML encoding replaces certain characters that are semantically meaningful in HTML markup, with equivalent characters that can be displayed to the user without affecting parsing the markup.

    The most significant and obvious characters are <, >, &, and ” which are are replaced with &lt;, &gt;, &amp;, and &quot;, respectively. Additionally, an encoder may replace high-order characters with the equivalent HTML entity encoding, so content can be preserved and properly rendered even in the event the page is sent to the browser as ASCII.

    HTML attribute encoding, on the other hand, only replaces a subset of those characters that are important to prevent a string of characters from breaking the attribute of an HTML element. Specifically, you’d typically just replace “, &, and < with &quot;, &amp;, and &lt;. This is because the nature of attributes, the data they contain, and how they are parsed and interpreted by a browser or HTML parser is different than how an HTML document and its elements are read.


    In terms of how that relates to XSS, you want to properly sanitize strings from an outside source (such as the user) so they don’t break your page, or more importantly, inject markup and script that can alter or destroy your application or affect your users’ machines (by taking advantage of browser or platform vulnerabilities).

    If you want to display user-generated content in your page, you’d HTML encode the string and then display it in your markup, and everything they entered will be displayed literally without worrying XSS or broken markup.

    If you needed to attach user-generated content to an element in an attribute (for example, a tooltip on a link), you’d attribute encode to make sure the content doesn’t break the element’s markup.

    Could you just use the same function for HTML encoding to handle attribute encoding? Technically, yes. In the case of the meta question you linked, it sounds like they were taking HTML that was encoded and decoding it, then using that result as an attribute value, which results in encoded markup being displayed literally, if you follow.

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

Sidebar

Related Questions

While browsing I came across this blog post about using the Wikipedia API from
i came across this post http://www.webmasterworld.com/javascript/3066162.htm about how in javascript when you instantiate an
I just came across this post .It just nicely explains about configuring unicorn server
I just came across this post that talks about time measuring. I remember (I
So I came across this post about accessing CRM data from an external application.
I came across a post Find the minimum difference between two arrays and using
I was researching something and came across this blog post at buildstarted.com about model
About a month ago, I came across an amazing blog post about the challenges
I came across a post in SO where the algorithm is implemented in python
I came across this post pass array to method Java on how to pass

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.