Skip to main content
Inspiring
January 15, 2010
Answered

Changing font colors within an output string

  • January 15, 2010
  • 1 reply
  • 1324 views

Hi,

I'm not sure if this can even be done, if so I have no clue of what to research to try it. Maybe someone knows or could shed some light on this.

I have numerious pages that are using the following code to set page titles:

<cfset pagetitle = "ACCOUNT SIGN-IN">

Then there is one template page that will display these page titles within a header on the page accordingly.  It uses the following code:

<cfoutput><div style="padding-top:20px;padding-left:8px;">#ucase(pagetitle)#</div></cfoutput>

My problem is this, I need to figure out a way to make everything in the page title after the first word a different color.  So in this example above "ACCOUNT" would stay the default color then " SIGN-IN" needs to be blue.

Any thoughts?  Thanks in advance!

    This topic has been closed for replies.
    Correct answer BKBK

    > a way to make everything in the page title after the first word a different color.

    > So in this example above "ACCOUNT" would stay the default color then

    > " SIGN-IN" needs to be blue.

    <cfset titleFirstWord = listGetAt(pagetitle,1," ")>
    <cfset restPageTitle = listRest(pagetitle, " ")>
    <cfoutput><div style="padding-top:20px;padding-left:8px;"><span>#ucase(titleFirstWord)#</span> <span style="color:blue">#ucase(restPageTitle)#</span></div></cfoutput>

    1 reply

    BKBK
    Community Expert
    BKBKCommunity ExpertCorrect answer
    Community Expert
    January 15, 2010

    > a way to make everything in the page title after the first word a different color.

    > So in this example above "ACCOUNT" would stay the default color then

    > " SIGN-IN" needs to be blue.

    <cfset titleFirstWord = listGetAt(pagetitle,1," ")>
    <cfset restPageTitle = listRest(pagetitle, " ")>
    <cfoutput><div style="padding-top:20px;padding-left:8px;"><span>#ucase(titleFirstWord)#</span> <span style="color:blue">#ucase(restPageTitle)#</span></div></cfoutput>

    brianismAuthor
    Inspiring
    January 15, 2010

    Yes!! That did it! Thank you. Your knowledge is very much appreciated.

    BKBK
    Community Expert
    Community Expert
    January 15, 2010

    You're very kind, Brianism.