Wrapping text in a label in Jsp

I have a label tag in my jsp page.

<label class="FormLabel" id="titleName_id" ><%= request.getAttribute("titleName") != null ? request.getAttribute("titleName") : "" %></label>

<%= request.getAttribute("titleName") != null ? request.getAttribute("titleName") : "" %>   will give the title name.  When the title name is too long, I need it to be wrapped. Pls help
Who is Participating?
Yes you can specify the width in the div itself.
For example,

<div class="FormLabel" style="width:200px;">

Add this css to the class="FormLabel"

shaan432Author Commented:
I tried that. I added that entry in the css file for the formlabel class as follows.  But it didnt work. What else can be done

.FormLabel {
font-family: arial, sans-serif;
font-size: 10pt;
color: #336699;
text-decoration: none;
font-weight: normal;
line-height: normal;
height: 20px;
padding-top: 1px;
padding-right: 0px;
padding-bottom: 1px;
padding-left: 1px;

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

You can consider adding in a width: XXXXXXpx; to the css.
If you don't add in, then it will be 100% across the width of your browser window.

shaan432Author Commented:
cant i specify the width in the label tag itself instead in the css file? else it would be applicable to the  labels in the entire application.  whats ur suggestion.
You can specify a style in a <span> tag for your specific label.  Although you might want to create a class, and use it in your <label> tag.

Also, if your text in the label does not have any spaces or newlines in it, then it will not wrap.  In that case, you have to actually break up the string with code.
You can specify  like wrap="soft" or wrap="hard" fro wrapping the text
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.