How to define style for direct childs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • marss

    How to define style for direct childs

    I want to define style that have to be applied to cells of a specified
    table but not to any nested tables cells.
    I use:
    ..somestyle tbody tr td { background-color:red; }

    Such construction works in Firefox , but fails in IE.
    What am I doing wrong?

    Example:
    <html>
    <head>
    <style>
    ..somestyle tbody tr td { background-color:red; }
    ..t2 { background-color:green; }
    </style>
    </head>
    <body>
    <table class="somestyl e" border=1>
    <tr>
    <td>
    11111
    <table class="t2" border=1>
    <tr>
    <td>22222</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </body>

    TIA, Mykola

  • Christian Kirsch

    #2
    Re: How to define style for direct childs

    Am 13.06.2007 11:12 schrieb marss:
    I want to define style that have to be applied to cells of a specified
    table but not to any nested tables cells.
    I use:
    .somestyle tbody tr td { background-color:red; }
    >
    Such construction works in Firefox , but fails in IE.
    What am I doing wrong?
    AFAIK: nothing. This is, IIRC, a shortcoming of IE's implementation of
    CSS. If "implementation " is the correct term in this context.

    Comment

    • marss

      #3
      Re: How to define style for direct childs


      Christian Kirsch wrote:
      Am 13.06.2007 11:12 schrieb marss:
      I want to define style that have to be applied to cells of a specified
      table but not to any nested tables cells.
      I use:
      .somestyle tbody tr td { background-color:red; }

      Such construction works in Firefox , but fails in IE.
      What am I doing wrong?
      >
      AFAIK: nothing. This is, IIRC, a shortcoming of IE's implementation of
      CSS. If "implementation " is the correct term in this context.
      It is a pity. Thanks for answer.

      Comment

      • Bergamot

        #4
        Re: How to define style for direct childs

        marss wrote:
        I want to define style that have to be applied to cells of a specified
        table but not to any nested tables cells.
        >
        .somestyle tbody tr td { background-color:red; }
        >
        Such construction works in Firefox , but fails in IE.
        ..somestyle td td {background-color:white;}

        Will use a different style for nested cells. Don't forget to set a
        foreground color to go with that background.

        --
        Berg

        Comment

        • marss

          #5
          Re: How to define style for direct childs


          Bergamot wrote:
          >
          .somestyle td td {background-color:white;}
          >
          Will use a different style for nested cells. Don't forget to set a
          foreground color to go with that background.
          >
          --
          Berg
          Thanks. Unfortunately it impossible to set style for all nested tables
          because they are generated in runtime.
          Mykola

          Comment

          • Bergamot

            #6
            Re: How to define style for direct childs

            marss wrote:
            Bergamot wrote:
            >>
            >.somestyle td td {background-color:white;}
            >>
            >Will use a different style for nested cells. Don't forget to set a
            >foreground color to go with that background.
            >
            Thanks. Unfortunately it impossible to set style for all nested tables
            because they are generated in runtime.
            If you cannot predict how tables will be nested, assign a class selector
            to every table and go from there.

            You might want to rethink the whole structure, though.

            BTW, you multi-posted this in a.w.w. Multi-posting is bad. Cross-posting
            isn't very good, either, but is better than multi-posting.


            --
            Berg

            Comment

            • Ben Bacarisse

              #7
              Re: How to define style for direct childs

              marss <marss.ua@gmail .comwrites:
              Bergamot wrote:
              >>
              >.somestyle td td {background-color:white;}
              >>
              >Will use a different style for nested cells. Don't forget to set a
              >foreground color to go with that background.
              >>
              Thanks. Unfortunately it impossible to set style for all nested tables
              because they are generated in runtime.
              You may have missed the point of Bergamot's suggestion. I *think* he
              is suggesting that you set the colour for all tds:

              ..somestyle td {background-color:red;}

              to the colour you want to be special and then[1] set:

              ..somestyle td td {background-color:white;}

              to give all nested tds (at whatever nesting) to the colour you want.
              I.e. you set it *back* rather than try to select for only those you
              want to change (because IE won't let you).

              It is not ideal, but it does not sound obviously out of the question
              as you suggest.

              [1] Don't take then "then" too literally. This selector has higher
              specificity so than the other -- the order they appear in is immaterial.
              --
              Ben.

              Comment

              • Jukka K. Korpela

                #8
                Re: How to define style for direct childs

                Scripsit Christian Kirsch:
                Am 13.06.2007 11:12 schrieb marss:
                >I want to define style that have to be applied to cells of a
                >specified table but not to any nested tables cells.
                >I use:
                >.somestyle tbody tr td { background-color:red; }
                >>
                >Such construction works in Firefox , but fails in IE.
                >What am I doing wrong?
                >
                AFAIK: nothing.
                I'm afraid the combination of using nested tables and doing nothing wrong is
                pretty rare on Earth. Basically, nested tables are wrong, though there might
                be some special justification for them. In this case, that's very
                improbable - we can see that from the URL. (That is, from lack of a URL.)
                This is, IIRC, a shortcoming of IE's implementation of CSS.
                IE supports the ">" construct in selectors, starting from IE 7. Of course,
                there is still a huge number of people still using IE 6 and even older, for
                good and bad reasons.

                On the other hand, setting the styles for tables in general, then overriding
                them for any nested tables, as explained elsewhere in the URL, works even on
                IE 6 older.

                --
                Jukka K. Korpela ("Yucca")


                Comment

                • marss

                  #9
                  Re: How to define style for direct childs

                  Thank all.
                  I decide to assign class attribute to all cells of the parent table.
                  <table><tr><t d class="somestyl e_td"and so forth...
                  In my case it gives more predictable and reliable results and doesn't
                  impact underlying tables.

                  Thank all. I knew many new and interesting.
                  Mykola

                  Comment

                  Working...