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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:00:07+00:00 2026-05-25T20:00:07+00:00

Question: I need to put a linebreak inside my tooltip so it’s not all

  • 0

Question:
I need to put a linebreak inside my tooltip so it’s not all on one line. I use tooltipsy to generate my tooltips. It works by using the title attribute on any anchor tags with the class “hastipy” as the content of the tooltip.

So the code:

<a href="http://tooltipsy.com/" class="hastipy" title="Click here to go to the tooltipsy website">
     tooltipsy
</a>

Would be a link showing the text “tooltipsy” and when you hover over it, it would show “Click here to go to the tooltipsy website” in a tooltip.

However, what if I want to put a linebreak inside the tooltip?

This code:

<a href="http://tooltipsy.com/" class="hastipy" title="Click here to <br /> go to the tooltipsy website">
     tooltipsy
</a>

returns a bunch of errors when you validate it at http://validator.w3.org

So I came up with this javascript/jQuery (written by Jason Gennaro):

$('a').each(function(){
    var a = $(this).attr('title');
    var b = a.replace('lineBreak','\n');
    $(this).attr('title', b);
});

this code uses a keyword (lineBreak in this case) and replaces it with \n(<– linebreak?) so my code passes validation and still has the linebreak in it.

And this code works on jsfiddle (here is the example), but on my website inside the tooltip, it doesn’t. It inserts the \n, but it doesn’t remove the “lineBreak” like it’s supposed to.

Can anyone offer an explanation for this or even a possible fix for it?

Note:
I don’t want a suggestion for another tooltip method, tooltipsy is working perfectly for everything I need.

Result:
As it turns out, just using &lt;br /&gt; instead of <br /> worked perfectly.

  • 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-25T20:00:08+00:00Added an answer on May 25, 2026 at 8:00 pm

    Use a global replace call: .replace(/lineBreak/g,'\n');.

    If you want to add <br /> in your title attribute, use: &lt;br /&gt; (html entities).

    Also, JQuery automatically wraps the JavaScript inside $(document).ready(...). You should do the same:

    $(document).ready(function(){
        //HTML-modifying code here.
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need a strategy to put Intellij IDEA project files into Git. The main question
I need to put String content to xml in Java. I use this kind
Quick (and hopefully easy) question: I need to trigger a download of a PDF
This question comes close to what I need, but my scenario is slightly different.
I need to prepare for my exam and this is the probable question for
My question is quite relevant to something asked before but I need some practical
We have a question with regards to XML-sig and need detail about the optional
I need to reinforce the structure of a Microsoft Word document. EG: Style Question
Very direct question, i need to know if its possible and maybe where to
This is a subjective question, but I need opinions. I have a WinForms C#

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.