admin管理员组

文章数量:1314292

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 / 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...

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/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...

Share Improve this question asked Apr 15, 2013 at 3:21 user2264263user2264263 472 bronze badges 2
  • 2 Nop, that's not valid HTML. – elclanrs Commented Apr 15, 2013 at 3:22
  • According to the w3c validator there is no problem with it unless you're using xhtml, – Musa Commented Apr 15, 2013 at 3:47
Add a ment  | 

4 Answers 4

Reset to default 4

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>

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 acplish. I'm sure there are better ways.

Use &#13; or &#xD;

<a href="#" title="hello &#13; how are you" target="xxx"></a>

Title attribute should be a text.Title Attribute Ref

title = text [CS]; This attribute offers advisory information about the element for which it is set. Values of the title attribute may be rendered by user agents in a variety of ways. For instance, visual browsers frequently display the title as a "tool tip" (a short message that appears when the pointing device pauses over an object). Audio user agents may speak the title information in a similar context. For example, setting the attribute on a link allows user agents (visual and non-visual) to tell users about the nature of the linked resource:

本文标签: