I am using:

<apex:pageMessages escape="false" showDetail="true"/>

and creating the detail message using String.format with this pattern:

'{0} Payment Specification <a href="/{1}">{2}</a> for Date Range <a href="/{3}">{4}</a> ({5} - {6}).

But when presented the white space around the links is excessive:

enter image description here

Using the browser's "Inspect" feature it seems like the white space in the pattern string does not get merged with vertical whitespace that is also added. Removing the white space in the pattern string only helps a bit.

Is there a technique (CSS?) that solves this problem?

  • After inspecting the page found that <style> .message .messageText a { color: rgb(51, 51, 51); font-size: 91%; margin: 0px 8px; } </style> is applied to the anchor tag within the message. The spaces were removed when I changed margin to margin: 0px 0px and added the style to VF page. Will this help? – Hemant Jain Jun 13 at 11:36
  • 1
    @HemantJain You are right - it does. So changing the pattern to contain <a style="margin: 0px;" href="/{1}">{2}</a> fixes it. Please post as an answer and I'll accept. – Keith C Jun 13 at 11:44
up vote 5 down vote accepted

The anchor tag with page message is styled as below:

<style> 
.message .messageText a { 
   color: rgb(51, 51, 51); 
   font-size: 91%; 
   margin: 0px 8px; } 
</style>

The value 8px is adding extra spaces.

You can change the margin attribute to margin: 0px and add the style to VF page to eliminate the white-spaces.

Or, as you said, adding style directly to pattern would also work <a style="margin: 0px;" href="/{1}">{2}</a>

  • 1
    Great, thanks Hemant! – Keith C Jun 13 at 11:56

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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