Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Different color for each letter in specific words.

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #248928
    pixelmac
    Participant

    Hello,

    I have this sentence repeating on a site: “Home Sweet Home”
    I want this short sentence to have different colors for each word in it.
    The colors would be predefined for each letter in each word.
    The idea is that the client won’t have to use or do anything if they write this “Home Sweet Home” anywhere on the site.

    So if the CSS recognize that sentence, then Home would be styled like:
    H: blue
    o: green
    m: yellow
    e: red

    S: red
    w: yellow
    e: green
    e: green
    t: blue

    Any ideas how to do this? I know it’s possible.
    Thanks
    Dan

    #248931
    Paulie_D
    Member

    Javascript and regex.

    This is not possible with CSS alone.

    CSS styles elements and cannot detect content in those elements.

    #248932
    gearheartstudio
    Participant

    Found this answer on another site and converted it over to code pen

    http://codepen.io/gearheartstudio/pen/OboaJB

    should help

    #248933
    pixelmac
    Participant

    Great find.
    Thank you so much.
    Dan

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.