+ Start a Discussion
Paul McMurrughPaul McMurrugh 

Change Font Size Based on Number of Characters

Hi all,

I would like to know if there is a Visualforce condition based on how many characters there are? I would like to make some text smaller if it goes over 30 characters in length.

Raj VakatiRaj Vakati
Use this type of code 
<div style="text-align:center;font-weight:bold; background-color:{!IF(rec.length ==20,'red', 'blue')}">
            <apex:outputText value="{!rec.name}"/>
		Controller : - 
		public string getrec()

Raj VakatiRaj Vakati
You can use style attribute from the visualforce tags . 
v varaprasadv varaprasad
Hi Paul,

please check once below code.
string accName = 'varaprasad';

if(accName.length() > 5){
    accName = accName.substring(0,5);
Hope this helps,
please let me know in case you need any assistance.

Hi Paul McMurrugh,
I think you need to use javascript in your visualforce page.
for example:
var str = "Hello World!";
var n = str.length;

and you get length of string and you can make change according to length.
I think this may help you.