Forum Moderators: open

Message Too Old, No Replies

Word wrap in a button

         

lizat

8:32 pm on Nov 16, 2009 (gmt 0)

10+ Year Member



Dear Forumites,

I want to have a button with two rows on text on it - that wrap automatically without using an image to have this effect. I can change the size of the button but the text simply will not wrap.

Is this possible

thank you, liz

Fotiman

9:12 pm on Nov 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld! Yes, this is possible. You simply include the newline in the value for the button:

<input type="button" value="Hello
World">

or

<input type="button" value="Line 1
Line 2">

lizat

9:01 am on Nov 17, 2009 (gmt 0)

10+ Year Member



Dear Fotiman,

Thank you for trying to help.

I don't understand your suggestion, as far as I can see the code snippets are identical bar the contents of the value attribute, and when you say "newline" what do you mean I don't think you mean a "newline code" - or do you?. I am already using the value field and it is this content that I want to wrap for example:

 
<input type="button" value="Hello World ¦ the second line">

Where the vertical bar represents a line break.... What happens in my button is that text doesn't wrap it truncates.

For my current case I don't actually want to hard wire it, rather have it wrap as a consequence of the button size, but it would also be good to know if a line break "code" can be included in a text string to force it.

So the question remains how do I acheive this?

thanks................ liz

Fotiman

2:00 pm on Nov 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In your editor (notepad, or whatever), when you type the value between the quotes for the value attribute, simply press the Enter key on your keyboard where you want a new line. For example:

value="blah blah blah[Enter]
Now I am on a new line[Enter]
and now I am on a 3rd line"

When the button is rendered, each row of text will appear on a new line.

Fotiman

2:08 pm on Nov 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Alternatively, you can use &#10; to represent the line feed.

lizat

11:00 pm on Nov 17, 2009 (gmt 0)

10+ Year Member



Thank you I will have a go

liz