Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Using CSS how can i set different colours for one piece of text?

    The title of my website is 2 words. I want the first word to be a different color to the second.

    The editor I am using will not let me do this directly, nor will it let me input HTML into the title (although I can input it in other places on each page).

    So I was wondering how I would go about accomplishing this with CSS?

  • #2
    New Coder
    Join Date
    Feb 2012
    Posts
    23
    Thanks
    0
    Thanked 1 Time in 1 Post
    Hope this helps. Not quite sure what you wanted or what your able to do with your program.

    Code:
    div h1:first-child:first-letter { color:#red; }

  • #3
    New Coder
    Join Date
    Feb 2012
    Location
    Finland
    Posts
    59
    Thanks
    3
    Thanked 9 Times in 9 Posts
    I would do it like this;

    Lets pretend for a second your title is Hello World and you want Hello to be red and World to be blue.

    I would first write the HTML code something like this;

    <p><span class="redtext">Hello</span> <span class="bluetext">World</span></p>


    and into css;

    .redtext {
    color: red;
    }

    .bluetext {
    color: blue;
    }


    I would also change the font size and so on of course, but this way I would do the color swapping, with span tags.

    Hope this helps.

    -Riku

  • #4
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the fast response.

    The problem is, the editor I'm using won't let me put HTML into the title.

  • #5
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,208
    Thanks
    7
    Thanked 268 Times in 267 Posts
    Are you actually talking about the <title> tag? The content of that is not html, it is text. But if you're talking about an <h1> or other tag the would allow <span> or other tags, then you just need a better editor...

    Dave

  • #6
    Regular Coder
    Join Date
    Aug 2005
    Location
    MS
    Posts
    830
    Thanks
    10
    Thanked 79 Times in 77 Posts
    You are talking about the title tags between the head tags. Can not set CSS rules or change anything as it is text only between the opening/closing tags.
    ☠ ☠RON☠ ☠


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •