[SalesForce] Display the message if the size = 0 – visual force page

Is there a way to display a message if the list has 0 records? in VisualForce Page? so my idea is to display something like this in the Pageblock

 <apex:pageBlock title="Contacts">
      There are no records to display {!SelectedContacts.size=0}.
   </apex:pageBlock>

here is my visual force page actually I have:

<apex:pageblock id="Selected_PBS" title="Selected Contact"  >
  <apex:pageBlockTable value="{!SelectedContacts}" var="contact">
     <apex:column value="{!contact.Name}"/>
     <apex:column value="{!contact.Email}"/>
     <apex:column value="{!contact.Phone}"/>
  </apex:pageBlockTable>

Best Answer

Instead of using two pageBlocks you can conditionally render the title value in apex:pageBlock to show the availability and unavailability of Objects in list. I have modified only the title attribute in your code.

<apex:pageblock id="Selected_PBS" title="{!IF(SelectedContacts != NULL && SelectedContacts.size > 0,'Selected Contact','There are no records to display')}">
  <apex:pageBlockTable value="{!SelectedContacts}" var="contact">
    <apex:column value="{!contact.Name}"/>
    <apex:column value="{!contact.Email}"/>
    <apex:column value="{!contact.Phone}"/>
  </apex:pageBlockTable>
</apex:pageBlock>

Hope it helps.