2

There are ways to create one white space (&nbsp;, <br/>), but I don't know how to create multiple consecutive white spaces between two fields. I've tried using InputHidden fields, <br/> or &nbsp; consecutively, blank outputlabels, but none of these has created more than one white space on the page.

Any ideas?

Example of what I'm trying to re-create in Visualforce:

enter image description here

Edit: The accepted answer works if the visualforce page is in edit mode, but in view mode, this happens:

enter image description here

I used <apex:pageBlockSectionItem/> between Field 2 and Field 3, but <br/> after Field 4. So using <apex:pageBlockSectionItem/> on view mode is problematic.

1
  • Some context around why would help. You could try simply adding padding or margin to one of the fields
    – Eric
    Jul 29, 2017 at 13:36

1 Answer 1

3

You're using an apex:pageBlockSection, so you just need to add empty items, like this:

<apex:pageBlockSection>
    <apex:outputField value="{!obj.field1}" />
    <apex:pageBlockSectionItem />
    <apex:pageBlockSectionItem />
    <apex:pageBlockSectionItem />
    <apex:outputField value="{!obj.field2}" />
    <apex:outputField value="{!obj.field3}" />
4
  • I was just about to write this and answer my own question! I should do more research before posting next time. Thanks!
    – user34868
    Jul 29, 2017 at 14:13
  • 1
    @ESil This is a good question. I don't think there's anywhere that really just calls this out, so it's not something a typical developer would know until they need it.
    – sfdcfox
    Jul 29, 2017 at 14:27
  • I just edited my question to show a problem with using <apex:pageBlockSectionItem /> like this - may I ask what you think?
    – user34868
    Aug 8, 2017 at 17:55
  • 1
    @ESil View mode doesn't have the underlines normally (which is what you see between field 2-3, and can verify using standard page layouts using the "Blank Field" element), but using <br /> outputs a cell that will be underlined. If you need consecutive items there, try <apex:outputPanel/>.
    – sfdcfox
    Aug 8, 2017 at 19:22

You must log in to answer this question.