Results 1 to 4 of 4

Thread: p and table

  1. #1
    Join Date
    Nov 2007
    Posts
    151
    Thanks
    67
    Thanked 0 Times in 0 Posts

    Default p and table

    HTML:
    PHP Code:
    <p id="sab">
      
    Hello!
      <
    table>
         <
    tr>
              <
    td>1</td>
              <
    td>2</td>
         </
    tr>
      </
    table>
    </
    p
    CSS:
    PHP Code:
    p#sab{background: #ff0;}
    #sab table{background: #000; width:450px;} 
    Why does'nt the CSS affect on the table?

    Thanks!

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    because tables are stupid - they don't follow the rules the same way everyone else does. Try giving it its own id
    Code:
    #sabtable{ background: #000; width: 450px; }

  3. The Following User Says Thank You to traq For This Useful Post:

    d-machine (03-20-2010)

  4. #3
    Join Date
    Aug 2009
    Posts
    92
    Thanks
    0
    Thanked 9 Times in 9 Posts

    Default

    <style>
    p#sab{background: #ff0;}
    #sab table{background: #000; width:450px;}
    #gg{background: red;}
    #hh{background:silver;}
    #gg1{background:green;}
    #hh1{background:blue;}
    #gg2{background:yellow;}
    #hh2{backgroundink;}
    </style><p id="sab">
    Hello!
    <table>
    <tr>
    <td id=gg>1</td>
    <td id=hh>2</td>
    </tr><tr>
    <td id=gg1>1</td>

    <td id=hh1>2</td>
    </tr><tr>
    <td id=gg2>1</td>
    <td id=hh2>2</td>
    </tr>
    </table>
    </p>

  5. The Following User Says Thank You to stringcugu For This Useful Post:

    d-machine (03-20-2010)

  6. #4
    Join Date
    Sep 2008
    Location
    Seattle, WA
    Posts
    135
    Thanks
    1
    Thanked 11 Times in 11 Posts

    Default

    First off, you shouldn't put a table inside of a paragraph tag. Secondly, style the table specifically. You can't style the <p> tag and expect everything in it to be that way. Switch to a <div> tag and style the items inside of it like this:

    #sab p {
    background-color: #ff0;
    }

    #sab th {
    blah bblah;
    }

    #sab tr {
    blah blah;
    }

    Then wrap it all up:

    <div id="sab">
    <p>Here's some text about the table below</p>
    <table>
    <tr><td></td>
    </tr>
    </table>
    </div>

  7. The Following User Says Thank You to simcomedia For This Useful Post:

    d-machine (03-20-2010)

Bookmarks

Posting Permissions

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