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 887935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:18:37+00:00 2026-05-15T13:18:37+00:00

In my markup I am using HTML title attributes which I set by the

  • 0

In my markup I am using HTML title attributes which I set by the Tooltip property of various ASP.NET controls like an asp:Label. The content of those titles come from a database and I use data binding syntax, for instance:

<asp:Label ID="PersonLabel" runat="server" 
    Text='<%# HttpUtility.HtmlEncode(Eval("PersonShortName")) %>'
    ToolTip='<%# HttpUtility.HtmlEncode(Eval("PersonFullName")) %>' />

Now, tooltips seem to be displayed as plain text on Windows and in the browsers I have tested. So the HTML-encoding is not what I really want and I am inclined to remove the encoding.

Can this be dangerous in any way if the database fields may contain script tags for example? My question is basically: Is it always guaranteed that HTML-title attributes are displayed as plain text? Are they always displayed as tooltips at all, or is it possible that some browsers (or OSs) display them in another way and allow and render HTML content in the title attributes?

Edit:

Looking at some of the answers it seems I didn’t phrase my question well, so here are some additions:

If I have in the code snippet above a PersonShortName of “PM” in my database and as the PersonFullName a name with non-ASCII characters in it like Umlauts in “Peter Müller” the browser displays in the tooltip Peter M&#252;ller when I apply HttpUtility.HtmlEncode like in the code example – which is ugly.

I’ve also tested a simple HTML fragment like:

<span title="<script>alert('Evil script')</script>" >Hello</span>

The script in the title attribute didn’t run in a browser with enabled Javascript (tested with Firefox), instead it was displayed in the tooltip as plain text. Therefore my guess was that title attributes are always rendered as plain text.

But as Felipe Alsacreations answered below there exist “rich tooltip plugins” which may render the title attribute as HTML. So in this case encoding is a good thing. But how can I know that?

Perhaps HttpUtility.HtmlEncode isn’t the right solution and I have to filter only HTML tags but not encode simple special characters to make sure that the plain text is displayed correctly and to protect “rich HTML tooltips” at the same time. But it looks like a costly work – only for a simple tooltip.

  • 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-15T13:18:38+00:00Added an answer on May 15, 2026 at 1:18 pm

    Always sanitize output to the browser.

    If a value like "><script>blabla</script> is inserted as a value for your fields, a user can essentially take over your entire site. It will probably make a mess when it comes to validation and correct code, but the script will still be run.

    So to answer your question: No, it is not guaranteed that HTML-title attributes are displayed as plain text if the user knows what he/she is doing.

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

Sidebar

Related Questions

I am using curl like this: curl -s -F uploaded_file=@/path_to_file;type=text/html -F output=soap12 http://localhost/w3c-markup-validator/check >text.xml
I'm trying to create css buttons by using the following html markup: <a href=access.php
i'm having the following markup using 2 divs. the #child div has set position:absolute;
I'm using python Textile to store markup in the database. I would like to
How does one go about catching exceptions from using controls in markup? For example,
I have the following jQuery Mobile HTML code, the navbar's content is set using
I have the following HTML markup: <body> <div class=wrapper> <div class=head> <p class=title>title</p> <a
I'm using ASP.NET MVC2 and C#, but this question applies to ASP.NET in general.
i am using this way to bind ASP.NET GridView Without postback. i want to
I am using the following html markup and css code to design my landing

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.