SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Wizard jag5311's Avatar
    Join Date
    Jan 2003
    Location
    Somewhere in Indiana
    Posts
    3,082
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    css class question

    If there is something like this


    td.main

    Does that mean that any table cell that has something with the class of Main will have "x" attributes?

    and so if it was

    td #main

    that would be only table cells that have an object of id="main" would contain "x" attributes?

    When is it useful to use td.main instead of just using .main by itself?

    Thanks
    Bryan

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by jag5311
    When is it useful to use td.main instead of just using .main by itself?
    Either when you know that table cells only will have the "main" class, or if you plan on assigning different styles to different elements with the same class (i.e. "a.main", "td.main", "span.main", etc.)

  3. #3
    SitePoint Enthusiast agentolivia's Avatar
    Join Date
    Jul 2003
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In considering class vs. id, use class (.classname) if you're going to use the same class name more than once on a page and id (#idname) if you're only using it only once on a page (like for layout purposes or a header or footer, for example). I don't think the page will validate (XHTML 1.0 Strict or Transitional) if you use the same id name more than once on a page.

  4. #4
    SitePoint Wizard jag5311's Avatar
    Join Date
    Jan 2003
    Location
    Somewhere in Indiana
    Posts
    3,082
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, i have another one for you

    I have a table, and I gave it an id of "featured".

    Well, I want the images and links in that table to be centered, so I did this

    #featured img, a {
    text-align: center
    }

    Well guess what, its not working. Any reason why?

    Thanks
    Bryan

  5. #5
    SitePoint Enthusiast agentolivia's Avatar
    Join Date
    Jul 2003
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink

    Try this:
    Code:
    table#featured td  {
    text-align: center
    }
    Edit:
    Took out the img,a.
    The above code will center everything in all the <td>s in table id="featured".
    Last edited by agentolivia; Sep 18, 2003 at 09:08.

  6. #6
    SitePoint Wizard jag5311's Avatar
    Join Date
    Jan 2003
    Location
    Somewhere in Indiana
    Posts
    3,082
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, you know what. That first example you gave me only worked if I put a comma between the

    td, img, a

    not,

    td img, a

  7. #7
    SitePoint Wizard jag5311's Avatar
    Join Date
    Jan 2003
    Location
    Somewhere in Indiana
    Posts
    3,082
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here, I have put an example page up. This is what I want it to look like in every browser except IE, because IE already seems to understand.
    http://www.somethingspecialgiftbaske.../test/test.htm

    Also, there is a damn gap right between the header and the content table. Annoying.

    ---EDIT----

    Ok, i figured out the table centering deal, i added margin-right: auto and margin-left: auto to table#maintable
    Last edited by jag5311; Sep 17, 2003 at 18:47.

  8. #8
    SitePoint Zealot Tygger2512's Avatar
    Join Date
    Jul 2003
    Location
    Pittsburg, KS
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by agentolivia
    Try this:
    Code:
    table#featured td img,a  {
    text-align: center
    }
    Correct me if I'm wrong, but won't the above code make all <a> tags centered? If the aim is to have all <img> and <a> tags within the <table id="featured"> tag appear centered then wouldn't the code have to be:

    Code:
    table#featured td img, table#featured td a  {
      text-align: center
    }
    Andy.
    Learn the Emotional Freedom Technique at www.as-if-by-magic.com

  9. #9
    SitePoint Wizard jag5311's Avatar
    Join Date
    Jan 2003
    Location
    Somewhere in Indiana
    Posts
    3,082
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well first off, the one you put in quotes DID NOT work. Once I added a comma between the td and img, it DID work

  10. #10
    SitePoint Enthusiast agentolivia's Avatar
    Join Date
    Jul 2003
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey guys, sorry about the confusion. I edited my earlier post and took out the img,a. See Andy's correction if you want to get ultra-specific (like I attempted at first). But after looking at your code , it looks like all you have in table id="featured" is <img>s and <a>s, so it doesn't seem necessary.


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
  •