1

I have:

  <label for="request-true">True</label>
  <apex:inputCheckbox id="request-true"/>

Result:enter image description here

Desired Result: True [ ]

2

To line up a label and a inputCheckbox in a row. There can be many solution to do this alignment. I am sharing the one way of doing this:

Code:

<apex:page >
<apex:form >
  <table>
  <td style="padding: 4px ! important;"><label for="request-true">True</label></td>
  <td><apex:inputCheckbox id="request-true"/></td>
  </table>
  </apex:form>
</apex:page>

Output:

enter image description here

1

I copy paste your code into my VF page and it seem aligned.Check out the pic below.

enter image description here

I suspect ,your code contain CSS that control the style.You may want to check it using Inspect Element in Chrome.

0

If you are inside an apex:pageBlockSection and want the standard styling:

<apex:pageBlockSection>
    ...
    <apex:pageBlockSectionItem>
        <apex:outputLabel for="request-true" value="True"/>
        <apex:inputCheckbox id="request-true"/>
   </apex:pageBlockSectionItem>
   ....
</apex:pageBlockSection>
0

Because Visualforce uses typical HTML, you could even include Bootstrap to not only align labels and fields, but also make your pages suitable for mobile.

Once you've included it via either a static resource or linked to a CDN, you can reference some of Bootstrap's classes with your forms. There's a few, different ways of doing this. Here's an example though:

<apex:form>
  <div class="form-control>
      <div class="col-md-4">
        <label for="request-true">True</label>
      </div>
      <div class="col-md-8">
        <apex:inputCheckbox id="request-true"/>
      </div>
  </div>
</apex:form>

Although there's different (and better) examples than the one I've provided here. But that would work and be responsive in mobile.

The only piece of advice I'd give you is to try to avoid using tables where possible.

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.