SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Evangelist jkh1978's Avatar
    Join Date
    May 2001
    Location
    Northern Virginia
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    css to set text in a table

    how would i define the text color in the css if my page is like this...

    <div = "menu">
    <table>
    <tr>
    <td bgcolor = "#880000">
    <p>This is the text I want blue</p>
    </td>
    </tr>
    </table>
    </div>

  2. #2
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would do it like this:

    Code:
    p     {color: #0000FF;}
    Or, if you want to assign a special class to the <p> inside the table cell, you should use:

    Code:
    p.blue     {color: #0000FF;}
    And you should call on this class like:

    Code:
    <div = "menu"> 
    <table> 
    <tr> 
    <td bgcolor = "#880000"> 
    <p class=blue>This is the text I want blue</p> 
    </td> 
    </tr> 
    </table> 
    </div>
    The code I posted does belong in an external stylesheet. Give me a buzz if you don't know how that works.

  3. #3
    SitePoint Addict cyberprince's Avatar
    Join Date
    Sep 2001
    Location
    Asia
    Posts
    334
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're really targetting just that table i think marks suggestion of assigning a class would work best.

  4. #4
    SitePoint Evangelist jkh1978's Avatar
    Join Date
    May 2001
    Location
    Northern Virginia
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    div tag

    What does the <div> do? I thought that that gave me a label to the section. I need to show that this <p> in the table is different that the <p> for the rest of the document.

    The class would work, but I thought that I could take advantage of the div=menu.

  5. #5
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I never use the <div> tag, when I am building a site. The class will distinguish the <p class=blue> from all the other <p>-tags you use in the document. This allows you to do what you wanted to accomplish.

    The best option you have in my opinion, is to use a stylesheet. This is also quite useful when your site is content-heavy, or starting to become like that. This allows you to implement a simple change, for example the font used, on all pages.

  6. #6
    .net install meltdown
    Join Date
    May 2001
    Location
    View Ridge
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are only going to be using the menu <div> once on the page, you can also utilize id for the menu vs class for each individual <p> tag.

    To identify an id in your stylesheet:

    Code:
    #menu {some css attributes for your div}
    Then you could specify attributes for all <p> tags within the id:

    Code:
    #menu p
     {
     color:#0000ff;
     }
    This will assign the color:#0000ff; to every <p> tag within the <div id="menu"> & save you having to assign class="foo" to every <p> tag.

    HTH

  7. #7
    SitePoint Guru
    Join Date
    Sep 1999
    Location
    Singapore
    Posts
    854
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could do:

    div.menu p {
    color : #0000FF;
    }

    <edit>
    Looks like isotope235 beat me to it.
    </edit>

  8. #8
    SitePoint Evangelist jkh1978's Avatar
    Join Date
    May 2001
    Location
    Northern Virginia
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    div

    Thats what I thought... but it wasnt working. It was taking the <p> characteristics from when I just definied p

    Thanks for your help... I will post my specific code later.


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
  •