Insert line break (enter) using HTML codes

Asked

Viewed 105,429 times

15

I’m trying to enter/break a line (\n, <br />, etc) in a title an html element. To do so, I searched for HTML Codes something that was equivalent to &nbsp used to give a "space". I found few references but none that actually worked...

I found the &#10 but it doesn’t work (source).

How can I actually enter/break a line title of an html element?

Code:

<input type="button" value="butão" title="tesxto 1 &#160 texto 2"/>

http://jsfiddle.net/pymgx0ws/

Edit:

In my application I’m using devexpress, and I can’t use:

<a title='1ª linha
2ª linha
3ª linha
'>link</a>
  • 1

    That wouldn’t be a XY problem?

  • Maybe, but if there’s an HTML Code for space, I think it exists for enter as well. I might be wrong, but if it’s not for HTML Code I don’t think I can enter :)

  • @Papacharlie, you don’t know how much sense it makes in my case whether or not to use a line break to separate information. I’ll give you my example: I have a listing with 18 columns, with so many columns I felt the need to replace some of the columns with icons, and the user passing the cursor over can know what the information of the respective column is. In this case when you hover the cursor on the icon, you can tell which user you created, ENTER, which user changed the line data

  • @Papacharlie, I’m using the bootstrap tooltip to do just that. But it asks that the text to be displayed in the tooltip be set in the title

  • http://jsfiddle.net/21p5swbw/, see if this is what you want

  • Yes, that’s what I want. I just have a problem: I’m using devexpress and it doesn’t allow you to enter’s to define the element. And since &nbsp works perfectly, I thought there was one for enter

Show 1 more comment

1 answer

17


jsfiddle

Use &#013; for line breaking

<a title='1ª linha&#013;2ª linha&#013;3ª linha'>link</a>

output

1ª linha
2ª linha
3ª linha

source

  • 1

    Interesting, did not know this. Congratulations, +1.

  • 1

    Also did not know, I was looking for how to escape enter to format in bootstrap and found in the OS but forgot to put the source... Then I’ll find out why tooltip not accept the <br> and update if there is information.

  • 1

    I didn’t know that one, no, very cool.

  • I did some tests and it didn’t work.

  • @lorduakiti the example of jsfiddle didn’t work?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.