Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it valid for Title attribute for <a> tag to hold html tags like <br> for new line

My question here is it really valid for a title attribute to hold html tags like break tag for new line.

  <a href="#" title="hello <br> how are you" target="xxx"></a>

If its valid then break tag shows in tool tip which i want to avoid but still need a new line.

I am using jQuery.

I referred a link http://jsfiddle.net/roXon/N8Q2z/ in which i gave break tags in title. It just works fine in achieving new line without break tag being displayed in tool tip.

But not sure which part of the code is avoiding break tags in tool tip.

Can you please let me know which piece of code in jquery actually avoids break tags being displayed in tool tips as i am new to jquery.

Would appreciate all your help!!

Thanks in advance...

like image 407
user2264263 Avatar asked Apr 15 '13 03:04

user2264263


3 Answers

Try using <br /> but use the values &lt; for < and &gt; for >. This will means that when the title is put into your tooltip it will be the correct format, and its valid!

Tested in IE7+, Chrome, Firefox.

jsFiddle

<a title="hello&lt;br/&gt;how are you" class="printbtn" href="#">Print results</a><br>
like image 55
Daniel Imms Avatar answered Sep 18 '22 22:09

Daniel Imms


Attribute values cannot contain tags. You can put new lines in the attribute values, but that's probably not a good idea.

It's a good time to think about why you want to put tags in the attribute and what you want to accomplish. I'm sure there are better ways.

like image 40
Michael Avatar answered Sep 20 '22 22:09

Michael


Use &#13; or &#xD;

<a href="#" title="hello &#13; how are you" target="xxx"></a>
like image 24
Tamil Selvan C Avatar answered Sep 22 '22 22:09

Tamil Selvan C