3

The text in my pageblock title is wrapping by default.

<apex:pageBlock title = "xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz "> 

How do I put it on one line? I tried making the title a child, but the font sizes were off...

<style type="text/css">
.pbTitle {
    white-space: nowrap
}
</style>
<apex:pageBlock>
 <b>
A very long title since it really is more like a help text to let people know what will be happening next and as such it will wrap around on the screen somehow... and so on and son on  ...
</b>
</apex:pageBlock>
6

You can control the break of the text using some CSS in the VF page:

<style type="text/css">
    .pbTitle {
        white-space: nowrap
    }
</style>

This will cause the text within that table cell not to wrap.

  • I'd already tried adding no-wrap attribute. Pageblock titles don't like that. – PartOfTheOhana Apr 23 '13 at 16:42
  • Please add to your question the markup which the pageblock title "didn't like". This style attribute when applied to either the td.pbTitle or to the h2.mainTitle rendered elements work exactly as you desire. – Mark Pond Apr 23 '13 at 16:50
  • i updated the code. It prevents the wrapping of the text, but the font size was off, when the title was a child. When the title is an attribute, it works. Why is that? – PartOfTheOhana Apr 24 '13 at 16:29
  • The difference is the HTML that is rendered by the apex:pageBlock tag. The title attribute becomes an h2 tag within the div that is the pageblock header while the other markup becomes a child node within the div that is the pageblock's body. If you are interested in adding instructional text in the pageblock body, you will need to style your own markup or leverage a pageMessage as @Ralph suggests. – Mark Pond Apr 24 '13 at 19:04
3

If you're looking to present some help text instructions to the user I find a page message tag looks nicer than cramming a bunch of text into the page block title.

<apex:pageBlock title="Do stuff">
  <apex:pageMessage severity="info" strength="3" summary="Instructions for want to do in this page block"/>
</apex:pageBlock>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.