css can you reference an element withen an element

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #1

    css can you reference an element withen an element

    The title might not make sense, but I wasn't sure how to word it.
    Lets say I have the following code (which is auto generated so I cannot supply an id or class in the caption element)
    [code=html]
    <table class="gv" id="gvClientTra cking" >
    <caption >
    Client Sites(10)<br/>
    </caption>
    <!-- etc, assume correct table structure and closing tags -->
    [/code]

    I can say in CSS
    [code=css]
    caption
    {
    text-align: left;
    }
    [/code]

    But I was really wondering if I could do something like
    [code=css]
    #gvClientTracki ng caption
    {
    text-align: left;
    }
    [/code]

    Or in some manor refer to ONLY caption elements that come inside an element with the id "gvClientTracki ng" (or elements with class "gv" would be ok too)

    I really though I had read about this once, but cannot figure out how to look it up now.

    Is that possible, or am I getting it confused with some xml styling abilities?
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    Yes you can using CSS "selectors" . Unfortunately, they only work in modern browsers and not Internet Explorer though IE7 can handle a few of them with bugs. I'm heading out the door so here's a link to the spec or you can google for a tutorial on it. Here's a link to what works in which browsers.

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      Hmm well the goodnews for me is it works in ie6/ff3/chrome.2 with the
      [code=css]
      .gv caption
      {
      }
      [/code]
      selector type. That should handle everything I need for this instance.

      Comment

      Working...