CSS help

Discussion in 'CSS' started by jason_79, Jun 8, 2014.

  1. #1
    is there a way to put style on <div>8</div> using css? thanks
    <div class="parent">
        0
        <div>
            1
            <div>
                <div>2</div>
                <div>3</div>
                <div>
                    4
                    <div>
                        5
                        <div>6</div>
                        <div>7</div>
                        <div>8</div>
                    </div>
                </div>
    
            </div>
        </div>
    </div>
    HTML:

     
    jason_79, Jun 8, 2014 IP
  2. shemseddine

    shemseddine Active Member

    Messages:
    144
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    55
    #2
    you can always give it an ID or a class and then style it. But you can do
    parent div div div:nth-child(3) div div:nth-child(3){}
    Code (markup):
     
    shemseddine, Jun 8, 2014 IP
  3. wiicker95

    wiicker95 Well-Known Member

    Messages:
    438
    Likes Received:
    37
    Best Answers:
    10
    Trophy Points:
    100
    #3
    If I had to have so many nested DIV on a page, I'd plain and simply put a bullet in my head. That said, you shouldn't even bother adding any DIV in your markup before building a proper, semantic structure around the almighty CONTENT.

    That aside, if the style you want to apply to <div>8</div> is any different that the one you'd apply to <div>6</div> and <div>7</div>, it probably means that it should have its ID/class. In practice however, the markup you have by now is.... not Scottish.
     
    wiicker95, Jun 8, 2014 IP
  4. jason_79

    jason_79 Greenhorn

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #4
    Thanks for the reply i know its better to put class or id on it, but unfortunately i dont have access on that html, its generated by the 3rd party software. May be will try shemsheddine code.
     
    jason_79, Jun 8, 2014 IP