Forums

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

Home Forums CSS Help with html5 header and css

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #31454
    asw
    Participant

    I am trying to create a header and would like to have the first letters of each word in the name stylized differently than the rest of the name. So this is what I did:


    T

    he

    C

    ompany

    N

    ame


    There has to be a better, cleaner way to do this, but if there is I don’t know it. Hopefully someone out there can help.
    Thanks,
    Aaron

    #63141
    TT_Mark
    Member

    There is a pseudo element in CSS called :first-letter. Not supported in all browsers but then nothing you’re already doing is ;-)

    #63177
    sliver37
    Member

    Strictly HTML + CSS-wise you could do (as ChristopherBurton said) span tags.

    The Company Name

    And in the CSS you would do something like:


    h1 { color: blue; }
    h1 span { color: red; }

    I’m sure there are Javascript techniques that could also achieve it, and as TT_Mark suggested :first-letter (which is the cleanest way by far) though good old spans have the widest browser support.

    #63178
    asw
    Participant

    I appreciate the span technique which is probably what I will end up doing.
    When I try ::first-letter, I am having to place each word in a different h1, otherwise the only thing that happens is the the first letter of the first word is affected. That doesn’t seem like how first-letter was supposed to work?

    #63179
    TT_Mark
    Member

    First letter only affects the first letter of each word, but then you can place each word in a span tag

    #63181
    sliver37
    Member

    Yeah first-letter should affect the first letter of each word, which I thought was the case. I haven’t really had a chance to use it to be honest.

    Either way, spans are definitely better than multiple H1 tags. Good luck with the rest of your site. :)

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