what is the proper styling convention?

Discussion in 'HTML' started by richard, Nov 14, 2013.

  1. richard

    richard Guest

    <div class="one">
    <div class="item">data</div>
    </div>
    <div class="two">
    <div class="item">data</div>
    </div>

    In this example I want to have "item" showing as one color in "one".
    Then in "two"showing as another color.
    How is this done properly?
     
    richard, Nov 14, 2013
    #1
    1. Advertising

  2. richard <> writes:

    > <div class="one">
    > <div class="item">data</div>
    > </div>
    > <div class="two">
    > <div class="item">data</div>
    > </div>
    >
    > In this example I want to have "item" showing as one color in "one".
    > Then in "two"showing as another color.
    > How is this done properly?


    The trouble with examples is that it's hard to determine what the
    general rule is. To apply a style to all elements with class "item" that
    are descendents of an element with class "two", you'd write

    .two .item { ... }

    (and analogously for class "one"). But all of these selectors work as
    well:

    .two div
    .two > .item
    div.two .item
    .two div:first-child

    and so on and so on. The "best" solution depends on exactly what the
    divs represent.

    --
    Ben.
     
    Ben Bacarisse, Nov 14, 2013
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roshawn

    Styling a control

    Roshawn, Aug 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    384
    clintonG
    Aug 21, 2004
  2. =?Utf-8?B?Y2RiaWdncw==?=
    Replies:
    0
    Views:
    399
    =?Utf-8?B?Y2RiaWdncw==?=
    Mar 12, 2006
  3. ={ Advocated }=

    Styling a table

    ={ Advocated }=, Sep 15, 2003, in forum: HTML
    Replies:
    17
    Views:
    701
    ={ Advocated }=
    Sep 16, 2003
  4. W. Paulisse

    styling buttons without CLASS

    W. Paulisse, Sep 29, 2003, in forum: HTML
    Replies:
    4
    Views:
    2,053
    Adrienne
    Oct 1, 2003
  5. e n | c k m a

    Styling radio buttons

    e n | c k m a, Dec 2, 2003, in forum: HTML
    Replies:
    4
    Views:
    618
    e n | c k m a
    Dec 3, 2003
Loading...

Share This Page