text-decoration:underline;

Discussion in 'CSS' started by eksplayer, Dec 15, 2006.

  1. #1
    I want to make my headings like this:
    • text: black
    • underline: blue

    But I don't know how, cause the property 'color' affect both the text and the underline - and then they get the same color :(

    Any ideas?
     
    eksplayer, Dec 15, 2006 IP
  2. iatbm

    iatbm Prominent Member

    Messages:
    5,151
    Likes Received:
    352
    Best Answers:
    0
    Trophy Points:
    360
    #2
    
    h1 { color : black; border-bottom: blue; }
    
    Code (markup):
    Tell us exactly for which headings you need this and do you need headings to be links etc etc .... a little more info please :D but you have code for what I understand you need up there ...
     
    iatbm, Dec 15, 2006 IP
  3. eksplayer

    eksplayer Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks, but I don't think I can use the property border-bottom. I will try to explain why.

    If I use border-bottom the "underline" gets wider than the text in the heading and I only want the underline to be the same width as the text, but in another color.
     
    eksplayer, Dec 15, 2006 IP
  4. eksplayer

    eksplayer Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    [​IMG]
     
    eksplayer, Dec 15, 2006 IP
  5. iatbm

    iatbm Prominent Member

    Messages:
    5,151
    Likes Received:
    352
    Best Answers:
    0
    Trophy Points:
    360
    #5
    play with width of the element .... that will probably make it work
     
    iatbm, Dec 15, 2006 IP
  6. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #6
    This is where the power of the segregating element, span, does the job.
    
    h1 {
        color: red;
        text-decoration: underline;
        }
        
    h1 span {
        color: blue;
        }
    =========
    <h1><span>generic header</span></h1>
    Code (markup):
    cheers,

    gary
     
    kk5st, Dec 15, 2006 IP
  7. eksplayer

    eksplayer Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    kk5st: Thanks, really nice :cool:
     
    eksplayer, Dec 15, 2006 IP