Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML: Newline character for label?

Tags:

html

I have a method that sets the text for a label, and I'd like to use it to display several lines of text. Is it possible to insert a character into the text for the label to do this?

like image 419
Mike Pateras Avatar asked Dec 16 '09 21:12

Mike Pateras


People also ask

How do I add a new line to a label?

When you click on the label Text property in the Property window for the label, a drop down will appear in which you can, when you press Enter , go to the new line.

How do you put a line break in label text?

You can also use <br/> where you want to break the text.

What does \n do in HTML?

The \n character matches newline characters.

What is \n line break?

Newline (frequently called line ending, end of line (EOL), next line (NEL) or line break) is a control character or sequence of control characters in a character encoding specification (e.g., ASCII, EBCDIC) that is used to signify the end of a line of text and the start of a new one.


2 Answers

You have a few choices. If you can trust your callers, you can allow formatted text to be passed into the parameter (so someone can pass "<br />" as part of the label text. If you can slightly trust them, you can still allow that one particular piece of HTML to come through while disallowing others, but you might want to put the intelligence in your function to limit how many breaks can come in one label.

Another (more obscure) choice would be to designate some other character or sequence of characters that you know will never appear on a label to indicate a break (e.g. "#NEWLINE"), and have the function substitute "<br />" wherever that occurs.

like image 137
Joe Mabel Avatar answered Sep 22 '22 10:09

Joe Mabel


Normally a simple <br/> tag will do it!!

like image 37
0xFF Avatar answered Sep 20 '22 10:09

0xFF