#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    293
    Rep Power
    11

    Is it possible to use p:nth-child inline on a DIV with P tags?


    Is it possible to use an inline version of the code below:

    Code:
    .content p:nth-child(3n+0){color:#c96;}
    I have a DIV, inside that div I have some P tags.
    I would like to set the "p:nth-child" using inline CSS on the DIV.

    Is that possible in one way or another?
    BongoBongo
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    11
    Rep Power
    0
    Don't see a reason you cannot give it a try
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    293
    Rep Power
    11
    Originally Posted by Anarasha
    Don't see a reason you cannot give it a try
    Well, that is why I ask the question here.
    I have tried and have not been able to make it work.

    So an example of how the inline use of nth-child in inline CSS for a DIV with P tags should look like, would be great
    BongoBongo
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    875
    Rep Power
    275
    I , honestly don't see how you would expect to use a style="" statement on the parent DIV and be able to target a P:child element since that style would only be able to affect the DIV itself.

    The only option I can see is actually using the
    Code:
    <style type="text/css">.content p:nth-child(3n+0){color:#c96;}</style>
    in the HEAD of your page and giving the parent DIV the class="content" .
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    293
    Rep Power
    11
    Originally Posted by DonR
    I , honestly don't see how you would expect to use a style="" statement on the parent DIV and be able to target a P:child element since that style would only be able to affect the DIV itself.

    The only option I can see is actually using the
    Code:
    <style type="text/css">.content p:nth-child(3n+0){color:#c96;}</style>
    in the HEAD of your page and giving the parent DIV the class="content" .
    You just copied my initial use of the nth-child ...
    I do not see why... my question was ... Is it possible to do it in the inline styles for e.g. a DIV.

    It should be a Yes or No answer...
    And if a Yes, then some example syntax would be nice.

    What to expect or not to expect... I'm not a CSS expert, that is why I'm asking this question in this forum in the first place.
    BongoBongo
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    875
    Rep Power
    275
    OK, then, IMHO, the answer would be "NO".
  12. #7
  13. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,128
    Rep Power
    4304
    CSS Selectors are for use in stylesheets. Inline styles don't use selectors. They apply directly to the element they are set on.
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).

IMN logo majestic logo threadwatch logo seochat tools logo