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 4 of 4
  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Embedding pseudo-element styles

    How can I embed pseudo-element styles? I had read somewhere that you can do something like this:
    Code:
    <p style="{}:first-line{color:#DD9900;}">
    nicely colored
    just regular
    </p>
    but that doesn't seem to work. What is the correct way to do this?

    *Must work in FF and IE.
    **Embedded child, sibling, adjacent, etc. would also be nice to know.

  • #2
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    Quote Originally Posted by darkmage784
    I had read somewhere that you can do something like this:
    Code:
    <p style="{}:first-line{color:#DD9900;}">
    nicely colored
    just regular
    </p>
    hrmmmmm... I've never heard of this. Where did you read this? I don't know that I would use it but it sounds like an interesting technique. You could always try
    Code:
    <p style="first-line{color:#DD9900;}">
    nicely colored
    just regular
    </p>
    …and see if that would work (thinking that the element part of the pseudo element wouldn't be needed).

    My immediate thoughts are that as long as you are embedding styles you might as well just use spans:
    Code:
    <p>
    <span style="color:#DD9900;">nicely colored</span>
    just regular
    </p>

  • #3
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    http://www.w3.org/TR/2002/WD-css-style-attr-20020515

    Being just a Working Draft, it isn't implemented (or even recommended to be implemented) in any browser.

  • #4
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    Yowsers. Thanks jkd... it's interesting, a working draft from 2002! Some pretty neat ways of integrating embedded styles, especially along the lines of this:
    3. Setting properties on a source anchor for each of its dynamic states, using pseudo-classes:

    <a href="http://www.w3.org/"
    style="{color: #900}
    :link {background: #ff0}
    :visited {background: #fff}
    :hover {outline: thin red solid}
    :active {background: #00f}">...</a>
    …but again I don't know how useful that would be given the benefits of an external stylesheet. (except for, say, CMS output?)


  •  

    Posting Permissions

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