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 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts

    different colored text in same heading

    Hi...

    First off, I am a total newbie when it comes to CSS. That said, here is the code I assume deals with the heading in question.


    #header { position: relative; height: 49px; background: #111; border-bottom: 1px solid #1c1c1b; font-family: Arial, Helvetica, sans-serif; }
    h1 { font-size: 3em; font-weight: bold; text-transform: lowercase; line-height: 50px; float: left; letter-spacing: -1px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; }
    h1 a { color: #89897c; }
    h1 a:hover { text-decoration: none; color: #CDCDBF }
    div.subtitle { line-height: 50px; font-size: 1.2em; color: #55554e; margin-left: 1em; float: left; text-transform: lowercase; }


    Suppose the heading is "BloggerTotality", how would I achieve the result that the words "Blogger" and "Totality" are both different colors, even though they are part of the same heading?

  • #2
    Regular Coder
    Join Date
    Nov 2006
    Posts
    247
    Thanks
    13
    Thanked 26 Times in 24 Posts
    Yeah, this is possible, and quite simple.
    Code:
    h1 a span { color: #xxxxxx; }
    Code:
    <h1><a href="">Blogger<span>Totality</span></a></h1>
    Last edited by Majoracle; 02-19-2009 at 09:23 AM.

  • Users who have thanked Majoracle for this post:

    nophster (02-19-2009)

  • #3
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello nophster,
    Have a look at this -
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    html, body {
    	font: 14px Arial, Helvetica, sans-serif;
    	background: #FC6;
    	text-align: center;
    }
    * {
    	margin: 0;
    	padding: 0;
    	border: none;
    }
    #wrap {
    	width: 800px;
    	margin: 30px auto;
    	background: #999;
    	overflow: auto;
    }
    #header { 
    	position: relative; 
    	height: 49px; 
    	background: #111; 
    	border-bottom: 1px solid #1c1c1b; 
    }
    h1 { 
    	font-size: 3em; 
    	font-weight: bold; 
    	text-transform: lowercase; 
    	line-height: 50px; 
    	float: left; 
    	letter-spacing: -1px;
    	margin-left: 20px;
    }
    h1 { color: #89897c; }
    span {color: #f00;}
    
    </style>
    </head>
    <body>
        <div id="wrap">
            <div id="header">
            	<h1>Bloggers<span>Totality</span></h1>
            <!--end header--></div>
        <!--end wrap--></div>
    </body>
    </html>
    Last edited by Excavator; 02-19-2009 at 10:18 AM. Reason: fix validation error
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • Users who have thanked Excavator for this post:

    nophster (02-19-2009)

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Quote Originally Posted by Ex
    Code:
    <div id="header">
            	<a href=""><h1>Bloggers<span>Totality</span></h1></a>
            <!--end header--></div>
    That markup is invalid!
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Oops, my mistake.
    I saw the :hover in his header CSS...
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #6
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks guys, I think I this will do the trick.

    Just for my info, if I wanted to do the same thing ONLY now I want to divide the heading into 3 colors, would I use <span> again for the third bit too?

  • #7
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Sure, span will work again. Do it with an id or a class though... like this:

    Code:
     <h1>First<span class="red">Second</span><span class="blue">Third</span></h1>
    Then your CSS might look like this:
    Code:
    h1 {
    color: #000;
    }
    .red {
    color: #f00;
    }
    .blue {
    color: #00f;
    }
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #8
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thank you, that helps a lot.


  •  

    Posting Permissions

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