Simple (hopefully) Table question

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

    Simple (hopefully) Table question

    I'd like to alternate the rows in a table between having a shaded
    background and being transparent to the background.

    It's a table of people's names, phone numbers, and beeper numbers. So,
    by having alternate rows be shaded, it will make it easier to read
    which number in the leftmost column belongs to the name in the
    rightmost column.

    Are there basic html tags to allow shading alternate rows by the whole
    table, rather than setting each one by hand? By that, I mean that
    people move into and out of the group at a fairly good rate, so, is
    there a tag I can put that covers the "whole" table and says
    "alternate background effects in these rows" rather than hand-setting
    the color of each background row?

    I'm sure this could be handled by CGI, but, I'm looking for non-CGI
    options to start.

    Gwen
  • David Dorward

    #2
    Re: Simple (hopefully) Table question

    Gwen Morse wrote:
    [color=blue]
    > I'd like to alternate the rows in a table between having a shaded
    > background and being transparent to the background.[/color]
    [color=blue]
    > Are there basic html tags to allow shading alternate rows by the whole
    > table, rather than setting each one by hand?[/color]

    No, and there shouldn't be. This is a presentational issue and therefore the
    job of CSS. Unfortunatly CSS doesn't have anything that can alternative
    styles (at least no yet), so you are limited to either using a lot of +
    styles ( tr {} tr + tr {} tr + tr + tr {} etc ) which aren't supported by
    MSIE, or giving class to every other <tr> element in the document.

    --
    David Dorward http://dorward.me.uk/

    Comment

    • Stephen Poley

      #3
      Re: Simple (hopefully) Table question

      On Sun, 05 Oct 2003 23:50:30 -0400, Gwen Morse <goldmoon@geoci ties.com>
      wrote:
      [color=blue]
      >I'd like to alternate the rows in a table between having a shaded
      >background and being transparent to the background.
      >
      >It's a table of people's names, phone numbers, and beeper numbers. So,
      >by having alternate rows be shaded, it will make it easier to read
      >which number in the leftmost column belongs to the name in the
      >rightmost column.
      >
      >Are there basic html tags to allow shading alternate rows by the whole
      >table, rather than setting each one by hand? By that, I mean that
      >people move into and out of the group at a fairly good rate, so, is
      >there a tag I can put that covers the "whole" table and says
      >"alternate background effects in these rows" rather than hand-setting
      >the color of each background row?
      >
      >I'm sure this could be handled by CGI, but, I'm looking for non-CGI
      >options to start.[/color]

      As David has said, this can't be handled by HTML/CSS. If you will be
      updating the table rather often, so that hand-editing is a nuisance, you
      could have a look at batch editors such as sed. Writing a sed script to
      do this sort of thing is a little fiddly (though it doesn't take long
      once you've got used to using the 'x' command), but a lot less work than
      setting up a server-side programming environment if you don't already
      have one.

      OTOH if you already have PHP available, that's probably the way to go.

      --
      Stephen Poley


      Comment

      • Stan Brown

        #4
        Re: Simple (hopefully) Table question

        In article <4ai1ov0mk8qd7p vcgps44kujvpt2d 87alh@4ax.com> in
        comp.infosystem s.www.authoring.html, Gwen Morse
        <goldmoon@geoci ties.com> wrote:[color=blue]
        >Are there basic html tags to allow shading alternate rows by the whole
        >table, rather than setting each one by hand?[/color]

        No.

        Either specify bgcolor in each td (_not_ tr), which is deprecated,
        or set up some CSS (which _can_ be applied to rows).

        Example -- in your HTML:

        <table class="striped" >
        <tr><td ... ... </tr>
        <tr class="otherstr ipe"><td ... ... </tr>
        <tr><td ... ... </tr>
        <tr class="otherstr ipe"><td ... ... </tr>
        ....
        </table>

        and then in your CSS file:

        table.striped tr td {color:#000; background-color:#C33}
        table.striped tr.otherstripe td {color:#000; background-color:#3C3}

        --
        Stan Brown, Oak Road Systems, Cortland County, New York, USA

        HTML 4.01 spec: http://www.w3.org/TR/html401/
        validator: http://validator.w3.org/
        CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
        2.1 changes: http://www.w3.org/TR/CSS21/changes.html
        validator: http://jigsaw.w3.org/css-validator/

        Comment

        Working...